Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "math.h"
- void main() {
- int n, i;
- int x1, x2, x3, y1, y2, y3;
- int a, b, c;
- int h, hmax=0;
- int pravougli = 0, imax = 0;
- printf("Unesite koliko trouglova zelite da unesete:\n");
- scanf("%d", &n);
- for (i = 0;i < n;i++) {
- scanf("%d%d%d%d%d%d", &x1, &x2, &x3, &y1, &y2, &y3);
- }
- a = (sqrt(x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
- b = (sqrt(x1 - x3)*(x1 - x3) + (y1 - y3)*(y1 - y3));
- c = (sqrt(x2 - x3)*(x2 - x3) + (y2 - y3)*(y2 - y3));
- if (c*c - a*a + b*b <= 0 || a*a + b*b - c*c <= 0 || b*b - c*c + a*a <= 0) {
- pravougli++;
- h = fmax(fmax(a, b), fmax(a, c));
- if (hmax < h)
- {
- hmax = h;
- imax = i;
- }
- }
- printf("pravouglih:%d, indeks max hipotenuze:%d", pravougli, imax);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement