#include #include struct position { double x; double y; }; struct segment { struct position pi; struct position pf; }; struct triplet { struct segment s1; struct segment s2; struct segment s3; }; double calculerLongueurSegment(struct segment s) { return sqrt(pow(s.pi.x - s.pf.x, 2.0) + pow(s.pi.y - s.pf.y, 2.0)); } double calculerLongueurMaxSegments(struct triplet trp) { double l1 = calculerLongueurSegment(trp.s1); double l2 = calculerLongueurSegment(trp.s2); double l3 = calculerLongueurSegment(trp.s3); if ((l1 >= l2) && (l1 >= l3)) { return l1; } if (l2 >= l3) { return l2; } return l3; } void main(void) { printf("%zu %zu %zu\n", sizeof(struct triplet), sizeof(struct segment), sizeof(struct position)); struct triplet trp = { { { 1.2, 3.4 },{ -2.3, 4.6 } }, { { 4.5,-5.6 },{ 7.2, 1.4 } }, { { -5.3, 0.0 },{ -1.3, 8.9 } } }; printf("%zu %zu %zu\n", sizeof(trp), sizeof(trp.s2), sizeof(trp.s2.pi)); printf("\n"); printf("Longueur maximale des segments : %lf\n", calculerLongueurMaxSegments(trp)); }