The_Law

Untitled

Dec 28th, 2017
650
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. void culc(void)
  6. {
  7.     FILE* in = fopen("input.txt", "r");
  8.     double x1,y1, x2, y2, x3, y3;
  9.     fscanf(in, "%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
  10.  
  11.     double s = ((x1 - x3) * (y2 - y3) - (y1 - y3) * (x2 - x3)) / 2;
  12.  
  13.     printf("%f\n", abs(s));
  14.  
  15.     double m1x = (x1 + x2) / 2;
  16.     double m1y = (y1 + y2) / 2;
  17.  
  18.     double m2x = (x2 + x3) / 2;
  19.     double m2y = (y2 + y3) / 2;
  20.  
  21.     double m3x = (x1 + x3) / 2;
  22.     double m3y = (y1 + y3) / 2;
  23.  
  24.     double res1 = /*Sqrt*/(pow(m1x - x3, 2) + pow(m1y - y3, 2));
  25.     double res2 = /*Sqrt*/(pow(m2x - x1, 2) + pow(m2y - y1, 2));
  26.     double res3 = /*Sqrt*/(pow(m3x - x2, 2) + pow(m3y - y2, 2));
  27.  
  28.  
  29.  
  30.     if (res1 > res2 && res1 > res3)
  31.         printf("%f", res1);
  32.  
  33.     if (res2 > res1 && res2 > res3)
  34.         printf("%f", res2);
  35.  
  36.     if (res3 > res2 && res3 > res1)
  37.         printf("%f", res3);
  38. }
  39.  
  40. int main(void)
  41. {
  42.     culc();
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment