Advertisement
NoxScourge

Untitled

Sep 10th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "math.h"
  3. void main() {
  4.  
  5. int n, i;
  6. int x1, x2, x3, y1, y2, y3;
  7. int a, b, c;
  8. int h, hmax=0;
  9. int pravougli = 0, imax = 0;
  10.  
  11. printf("Unesite koliko trouglova zelite da unesete:\n");
  12. scanf("%d", &n);
  13.  
  14.  
  15. for (i = 0;i < n;i++) {
  16.  
  17. scanf("%d%d%d%d%d%d", &x1, &x2, &x3, &y1, &y2, &y3);
  18.  
  19. }
  20.  
  21. a = (sqrt(x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
  22. b = (sqrt(x1 - x3)*(x1 - x3) + (y1 - y3)*(y1 - y3));
  23. c = (sqrt(x2 - x3)*(x2 - x3) + (y2 - y3)*(y2 - y3));
  24.  
  25.  
  26. if (c*c - a*a + b*b <= 0 || a*a + b*b - c*c <= 0 || b*b - c*c + a*a <= 0) {
  27. pravougli++;
  28. h = fmax(fmax(a, b), fmax(a, c));
  29. if (hmax < h)
  30. {
  31. hmax = h;
  32. imax = i;
  33. }
  34. }
  35.  
  36. printf("pravouglih:%d, indeks max hipotenuze:%d", pravougli, imax);
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement