{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# sol12 - 12 1#include typedef struct line_t cfw...

This preview shows pages 1–3. Sign up to view the full content.

'סמ ליגרת-תונכת סרוק 12 ןורתפל אמגוד 1 תודוקנו םירשי . #include <stdio.h> typedef struct line_t { double a; double b; } Line; typedef struct point_t { double x; double y; } Point; int doIntersect(Line l1, Line l2); Point intersectionPoint(Line l1, Line l2); int isPointOnLine(Line l, Point p); Line getLine(Point p1, Point p2); int main() { Line l1, l2, l3, l4; Point p,p1,p2; l1.a = 1; l1.b = -2; l2.a = -1; l2.b = 4; l3.a = 1; l3.b = 0; printf( "doIntersect(l1,l2)? %d\n" ,doIntersect(l1,l2)); printf( "doIntersect(l1,l3)? %d\n" ,doIntersect(l1,l3)); p = intersectionPoint(l1,l2); printf( "intersection point(l1,l2): (%g,%g)\n" ,p.x,p.y); p.x = 3; p.y = 1; printf( "point (3,1) on line l1?: %d\n" ,isPointOnLine(l1,p)); p.x = 3; p.y = 1.5; printf( "point (3,1.5) on line l1?: %d\n" ,isPointOnLine(l1,p)); p1.x = 0; p1.y = -2; p2.x = 3; p2.y = 1; l4 = getLine(p1,p2); printf( "line: %g %g\n" , l4.a, l4.b); return 0; } int doIntersect(Line l1, Line l2) { return (l1.a != l2.a) ? 1 : 0; } Point intersectionPoint(Line l1, Line l2) { Point interPt;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
interPt.x = (l2.b - l1.b)/(l1.a-l2.a); interPt.y = (l1.a * l2.b - l1.b * l2.a)/(l1.a-l2.a); return interPt; } int
This is the end of the preview. Sign up to access the rest of the document.
• Spring '09
• can'tsay
• Human mitochondrial DNA haplogroup, Human mtDNA haplogroups, scanf, printf, ‫1. ישרים ונקודות‬, ‫2. מצעד הפזמונים‬

{[ snackBarMessage ]}

### Page1 / 3

sol12 - 12 1#include typedef struct line_t cfw...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online