Advertisement
mfrankic

C

Apr 20th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #ifndef DEBUG
  5. #define DEBUG(...) printf(__VA_ARGS__)
  6. #endif
  7.  
  8. typedef struct {
  9.   int x;
  10.   int y;
  11. } point;
  12.  
  13. typedef struct {
  14.   point a;
  15.   point b;
  16.   point c;
  17. } triangle;
  18.  
  19. // Napisati funkciju za ucitavanje tocaka
  20. void load_points(int n, triangle t[]) {
  21.   for (int i = 0; i < n; i++)
  22.   {
  23.     scanf("%d %d %d %d %d %d", &t[i].a.x, &t[i].a.y, &t[i].b.x, &t[i].b.y, &t[i].c.x, &t[i].c.y);
  24.   }
  25.  
  26. }
  27.  
  28. float distance(point p1, point p2) {
  29.   return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
  30. }
  31.  
  32. float check_triangle(triangle t) {
  33.   // Napisati dio koda za provjeru ako je jedan trokut jednakokracan
  34.   float a, b, c;
  35.   a = distance(t.a, t.b);
  36.   b = distance(t.b, t.c);
  37.   c = distance(t.c, t.a);
  38.  
  39.   if (a == b || a == c || b == c)
  40.   {
  41.     return 1;
  42.   }
  43.  
  44.   return 0;
  45. }
  46.  
  47. int main() {
  48.   int n;
  49.   triangle t[128];
  50.  
  51.   scanf("%d", &n);
  52.  
  53.   // Napisati poziv funkcije za ucitavanje tocaka
  54.   load_points(n, t);
  55.  
  56.   for (int i = 0; i < n; i++) {
  57.     if (check_triangle(t[i])) {
  58.       printf("DA\n");
  59.     } else {
  60.       printf("NE\n");
  61.     }
  62.   }
  63.  
  64.   return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement