Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=26&page=show_problem&problem=2474 */
- #include <stdio.h>
- long int absoluto(long int);
- int main()
- {
- /* declaração de variáveis */
- long int dA;
- long int dB;
- long int dC;
- unsigned int uT;
- unsigned int uI;
- char *sTipo;
- fscanf(stdin, "%u", &uT);
- for(uI = 1; uI <= uT; uI++)
- {
- /* entrada dos lados */
- fscanf(stdin, "%ld %ld %ld", &dA, &dB, &dC);
- /* verifica se os lados compoem um triângulo válido */
- if( dA > 0 && dB > 0 && dC > 0 && ( absoluto(dB - dC) < dA) && (dA < (dB + dC)) )
- {
- if(dA == dB && dB == dC)
- sTipo = "Equilateral";
- else if(dA == dB || dA == dC || dB == dC)
- sTipo = "Isosceles";
- else
- sTipo = "Scalene";
- }
- else
- sTipo = "Invalid";
- /* imprime o tipo de triângulo */
- fprintf(stdout, "Case %u: %s\n", uI, sTipo);
- }
- return 0;
- }
- /* retorna valor absoluto */
- long int absoluto(long int dN)
- {
- if(dN < 0)
- return (-1 * dN);
- return dN;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement