/home/toolbox/public_html/solutions/114/11479/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 <stdlib.h>
7 #include <math.h>
8 #include <stdint.h>
9 #include <ctype.h>
10
11 #define TRUE (1 == 1)
12 #define FALSE (1 != 1)
13
14 #define DEBUG if (FALSE)
15
16 /* fprintf(stderr, "functionName: message", varslist); */
17
18 /*
19 * Author: Isaac Traxler
20 * Date: 2021-12-5
21 * Purpose: fun
22 * Problem: 11479 - Is this the easiest problem?
23 */
24
25 /*
26 * This template reads data a specified number of times.
27 */
28
29 int numberOfTimes;
30 int s1;
31 int s2;
32 int s3;
33
34 void init()
35 {
36 /* FUNCTION init */
37 scanf("%d ", &numberOfTimes);
38 } /* FUNCTION init */
39
40 void dump()
41 {
42 /* FUNCTION dump */
43 } /* FUNCTION dump */
44
45 void getInput()
46 {
47 /* FUNCTION getInput */
48 int tmp;
49
50 scanf(" %d %d %d ", &s1, &s2, &s3);
51 /* sort them in increasing order */
52 if (s1 > s2)
53 {
54 /* swap them */
55 tmp = s1;
56 s1 = s2;
57 s2 = tmp;
58 } /* swap them */
59 if (s2 > s3)
60 {
61 /* swap them */
62 tmp = s2;
63 s2 = s3;
64 s3 = tmp;
65 if (s1 > s2)
66 {
67 /* swap them */
68 tmp = s1;
69 s1 = s2;
70 s2 = tmp;
71 } /* swap them */
72 } /* swap them */
73 } /* FUNCTION getInput */
74
75 void process()
76 {
77 /* FUNCTION process */
78
79 DEBUG printf("DEBUG: %d %d %d ", s1, s2, s3);
80 if (0 >= s1)
81 {
82 /* a side is not positive */
83 printf("Invalid\n");
84 } /* a side is not positive */
85 else if ((s1 == s2) && (s2 == s3))
86 {
87 /* all 3 sides same length */
88 printf("Equilateral\n");
89 } /* all 3 sides same length */
90 else if ((s3 - s2) >= s1)
91 {
92 /* impossible two shortest sides can't reach long side */
93 printf("Invalid\n");
94 } /* impossible two shortest sides can't reach long side */
95 else
96 {
97 /* look for other cases */
98 if ((s1 == s2) || (s2 == s3))
99 {
100 /* 2 sides same length */
101 printf("Isosceles\n");
102 } /* 2 sides same length */
103 else
104 {
105 /* make sure longest side is smaller than sum of other 2 */
106 if ((s3 - s2) < s1)
107 {
108 /* yes -- valid triangle */
109 printf("Scalene\n");
110 } /* yes -- valid triangle */
111 else
112 {
113 /* ends do not connect */
114 printf("Invalid\n");
115 } /* ends do not connect */
116 } /* make sure longest side is smaller than sum of other 2 */
117 } /* look for other cases */
118 } /* FUNCTION process */
119
120 int main()
121 {
122 /* main */
123 int i;
124
125 init();
126 for (i=1; i<=numberOfTimes; i++)
127 {
128 /* while */
129 getInput();
130 printf("Case %d: ", i);
131 process();
132 } /* while */
133
134 return EXIT_SUCCESS;
135 } /* main */
136
137