/home/toolbox/public_html/solutions/118/11854/a.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <stdint.h>
7 #include <math.h>
8 #include <stdlib.h>
9
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 /*
16 * Author: Isaac Traxler
17 * Date: 2016-04-05
18 * Purpose: fun
19 * Problem: 11854 - Egypt
20 */
21
22 /*
23 * This template reads data until a terminating value is reached.
24 */
25
26 int sides[3];
27
28 void init()
29 {
30 /* FUNCTION init */
31 } /* FUNCTION init */
32
33 void dump()
34 {
35 /* FUNCTION dump */
36 } /* FUNCTION dump */
37
38 int getInput()
39 {
40 /* FUNCTION getInput */
41 int dataReadFlag;
42
43 scanf(" %d %d %d ", &sides[0], &sides[1], &sides[2]);
44 dataReadFlag = ((0 != sides[0]) || (0 != sides[1]) || (0 != sides[2]));
45 return (dataReadFlag);
46 } /* FUNCTION getInput */
47
48 int compare(const void *a, const void *b)
49 {
50 /* FUNCTION compare */
51 return ( *(int*)a - *(int*)b );
52 } /* FUNCTION compare */
53
54 void process()
55 {
56 /* FUNCTION process */
57 sides[0] = sides[0] * sides[0];
58 sides[1] = sides[1] * sides[1];
59 sides[2] = sides[2] * sides[2];
60 qsort(sides, 3, sizeof(int), compare);
61 if ((sides[0] + sides[1]) == sides[2])
62 {
63 /* right triangle */
64 printf("right\n");
65 } /* right triangle */
66 else
67 {
68 /* not a right triangle */
69 printf("wrong\n");
70 } /* not a right triangle */
71
72 } /* FUNCTION process */
73
74 int main()
75 {
76 /* main */
77 int moreToDo;
78
79 init();
80 moreToDo = getInput();
81 while (moreToDo)
82 {
83 /* while */
84 process();
85 moreToDo = getInput();
86 } /* while */
87
88 return EXIT_SUCCESS;
89 } /* main */
90