Advertisement
rvernucio

UVA 11479 - Is this the Easiest Problem?

Sep 29th, 2012
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=26&page=show_problem&problem=2474 */
  2. #include <stdio.h>
  3.  
  4. long int absoluto(long int);
  5.  
  6. int main()
  7. {
  8.  
  9.     /* declaração de variáveis */
  10.     long int dA;
  11.     long int dB;
  12.     long int dC;
  13.     unsigned int uT;
  14.     unsigned int uI;
  15.     char *sTipo;
  16.  
  17.     fscanf(stdin, "%u", &uT);
  18.     for(uI = 1; uI <= uT; uI++)
  19.     {
  20.  
  21.         /* entrada dos lados */
  22.         fscanf(stdin, "%ld %ld %ld", &dA, &dB, &dC);
  23.  
  24.         /* verifica se os lados compoem um triângulo válido */
  25.         if( dA > 0 && dB > 0 && dC > 0 && ( absoluto(dB - dC) < dA) && (dA < (dB + dC)) )
  26.         {
  27.             if(dA == dB && dB == dC)
  28.                 sTipo = "Equilateral";
  29.             else if(dA == dB || dA == dC || dB == dC)
  30.                 sTipo = "Isosceles";
  31.             else
  32.                 sTipo = "Scalene";
  33.         }
  34.         else
  35.             sTipo = "Invalid";
  36.  
  37.         /* imprime o tipo de triângulo */
  38.         fprintf(stdout, "Case %u: %s\n", uI, sTipo);
  39.     }
  40.  
  41.     return 0;
  42. }
  43.  
  44.  
  45. /* retorna valor absoluto */
  46. long int absoluto(long int dN)
  47. {
  48.     if(dN < 0)
  49.         return (-1 * dN);
  50.  
  51.     return dN;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement