• We just launched and are currently in beta. Join us as we build and grow the community.

Intersection of Random Two Lines From a Set of N Lines

B4l4nc3

Network Intelligence Aggregator
B Rep
0
0
0
Rep
0
B Vouches
0
0
0
Vouches
0
Posts
117
Likes
177
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 400 XP
This project will teach you how to get intersection of random two lines from a set of N lines. It was created using C/C++. This is very easy to do project. Download the project to see the full source code/

Please don't forget to like my page.

  1. #include<stdio.h>
  2. #include<ctype.h>
  3. #include<conio.h>
  4. #include<stdlib.h>

  5. int

    i=

    0

    ;
  6. int

    a1=

    0

    ,

    b1=

    0

    ,

    c1=

    0

    ;
  7. int

    detA =

    0

    ,

    det1 =

    0

    ,

    det2=

    0

    ;

    int

    l1=

    0

    ,

    l2=

    0

    ;
  8. float

    x=

    0

    ,

    y=

    0

    ;

    int

    lines ;

    int

    p=

    0

    ,

    q=

    0

    ,

    r=

    0

    ,

    s=

    0

    ;
  9. struct

    COF {
  10. int

    a =

    0

    ,

    b=

    0

    ,

    c=

    0

    ,

    k=

    0

    ;
  11. int

    count =

    0

    ;
  12. struct

    COF *

    next;
  13. }

    ;

  14. COF AccessLine(

    COF *

    A,

    int

    m)
  15. {

  16. do
  17. {
  18. if

    (

    A->

    count==

    m-

    1

    )

    {

    return

    *

    A;

    }

  19. else

    {

    A=

    A->

    next ;

    }
  20. }

  21. while

    (

    A->

    next->

    count!=

    1

    )

    ;



  22. }

  23. int

    main(

    void

    )

  24. {


  25. struct

    COF *

    P;
  26. P=

    (

    COF *

    )

    malloc

    (

    sizeof

    (

    COF)

    )

    ;
  27. struct

    COF *

    REF;
  28. REF=

    (

    COF *

    )

    malloc

    (

    sizeof

    (

    COF)

    )

    ;
  29. REF=

    P;



  30. printf

    (

    "Number of lines N= "

    )

    ;
  31. scanf

    (

    "%d"

    ,&

    lines)

    ;



  32. for

    (

    i=

    0

    ;

    i<

    lines ;

    i++

    )

  33. {
  34. printf

    (

    "Enter the Coficients of %d th line \n

    "

    ,

    i+

    1

    )

    ;
  35. printf

    (

    "Enter a[%d] = "

    ,

    i)

    ;
  36. scanf

    (

    "%d"

    ,&

    a1)

    ;
  37. printf

    (

    "Enter b[%d] = "

    ,

    i)

    ;
  38. scanf

    (

    "%d"

    ,&

    b1)

    ;
  39. printf

    (

    "Enter c[%d] = "

    ,

    i)

    ;
  40. scanf

    (

    "%d"

    ,

    &

    c1)

    ;
  41. P->

    a=

    a1;

    P->

    b=

    b1;

    P->

    c=

    c1 ;

    P->

    k=-

    1

    *

    c1;

    P->

    count=

    i;
  42. a1=

    0

    ;

    b1=

    0

    ;

    c1=

    0

    ;
  43. P->

    next=

    (

    COF *

    )

    malloc

    (

    sizeof

    (

    COF)

    )

    ;
  44. if

    (

    i==

    lines-

    1

    )

    {

    P->

    next=

    REF;

    }
  45. else

    {

    printf

    (

    "VALUE OF i is %d : \n

    "

    ,

    i)

    ;

    P=

    P->

    next;

    }

  46. }

  47. printf

    (

    "CIRCULAR LINKED LIST OR COEFICIENT LIST IS CREATED :PREE ANY LEY ... \n

    "

    )

    ;

  48. getch

    (

    )

    ;
  49. printf

    (

    "ENTER THE LINE NUMBER FOR LINE1 IN BETWEEN 1 AND %d : "

    ,

    lines)

    ;
  50. scanf

    (

    "%d"

    ,&

    l1)

    ;
  51. printf

    (

    "ENTER THE LINE NUMBER FOR LINE2 IN BETWEEN 1 AND %d : "

    ,

    lines)

    ;
  52. scanf

    (

    "%d"

    ,&

    l2)

    ;

  53. COF *

    LINE1=

    (

    COF *

    )

    malloc

    (

    sizeof

    (

    COF)

    )

    ;
  54. COF *

    LINE2=

    (

    COF *

    )

    malloc

    (

    sizeof

    (

    COF)

    )

    ;
  55. P=

    REF;
  56. *

    LINE1=

    AccessLine(

    P,

    l1)

    ;
  57. P=

    REF;
  58. *

    LINE2=

    AccessLine(

    P,

    l2)

    ;
  59. printf

    (

    "SUCESS .. PRESS ANY KEY ... : \n

    "

    )

    ;

    getch

    (

    )

    ;
  60. printf

    (

    "A line is is %d x + %d y + %d =0 : \n

    "

    ,

    LINE1->

    a,

    LINE1->

    b,

    LINE1->

    c)

    ;
  61. printf

    (

    "A line is is %d x + %d y + %d =0 : \n

    "

    ,

    LINE2->

    a,

    LINE2->

    b,

    LINE2->

    c)

    ;

  62. printf

    (

    "CALCULATING INTERSECTION : \n

    "

    )

    ;
  63. detA=

    LINE1->

    a*

    LINE2->

    b -

    LINE1->

    b*

    LINE2->

    a;
  64. det1=

    LINE1->

    a*

    LINE2->

    k -

    LINE2->

    a*

    LINE1->

    k ;
  65. det2=

    LINE2->

    b*

    LINE1->

    k -

    LINE1->

    b*

    LINE2->

    k;
  66. x=

    float

    (

    det2)

    /

    float

    (

    detA)

    ;
  67. y=

    float

    (

    det1)

    /

    float

    (

    detA)

    ;

  68. printf

    (

    "INTERSECTION OF LINES %d & %d IS : X CORD = %f , Y CORD %f :\n

    "

    ,

    l1,

    l2,

    x,

    y)

    ;
  69. printf

    (

    "END OF CODE : PRES ANY KEY ...... : "

    )

    ;

  70. getch

    (

    )

    ;

  71. return

    (

    0

    )

    ;
  72. }

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.

2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,526

323,535

Top