武汉科技大学ACM:1010: 零起点学算法27——判断是否直角三角形

Problem Description

输入三个整数,分别代表三角形的三条边长度,判断能否构成直角三角形

Input

输入3个整数a,b,c(多组数据,-5000000<a,b,c<5000000)

Output

如果能组成直角三角形,输出yes否则输出no

Sample Input

3 4 5

Sample Output

yes


 1 #include <stdio.h>
 2 int main()
 3 {
 4     int a, b, c;
 5     while(scanf("%d%d%d",&a,&b,&c)!=EOF)
 6     {
 7         if(a>0 && b>0 && c>0 && a+b>c && a+c>b && b+c>a)
 8         {
 9             if (a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)
10                 printf("yes\n");
11             else
12                 printf("no\n");                
13         }
14         else
15         {
16             printf("no\n");    
17         }
18         
19     }    
20     return 0;
21 }

 

posted @ 2014-12-16 19:55  liuwt365  阅读(1273)  评论(0编辑  收藏  举报