hdu 2039 三角形
三角形
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 171751 Accepted Submission(s): 55191
Problem Description
給定三條邊,請你判斷一下能不能組成一個三角形。
Input
輸入數(shù)據(jù)第一行包含一個數(shù)M,接下有M行,每行一個實例,包含三個正數(shù)A,B,C。其中A,B,C <1000;
Output
對于每個測試實例,如果三條邊長A,B,C能組成三角形的話,輸出YES,否則NO。
Sample Input
2
1 2 3
2 2 2
Sample Output
NO
YES

代碼:
#include<stdio.h>
int main()
{
int M;double A,B,C;
scanf("%d",&M);
while(M--&&scanf("%lf%lf%lf",&A,&B,&C))
{
if((A+B)>C&&(A+C)>B&&(B+C)>A)
printf("YES\n");
else
printf("NO\n");
}
}
評論
圖片
表情
