hdu ---2039做題筆記
阿新 • • 發佈:2019-01-29
三角形
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 76072 Accepted Submission(s): 25533
Problem Description 給定三條邊,請你判斷一下能不能組成一個三角形。
Input 輸入資料第一行包含一個數M,接下有M行,每行一個例項,包含三個正數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
Author linle
水題,不解釋了
#include <iostream>using namespace std; int main() { int n; while (cin >> n&&n) { int i; float a, b, c; for (i = 0; i < n; i++) { cin >> a >> b >> c; if (a + b > c&&a + c > b&&b + c > a) cout <<"YES"; else cout << "NO"; cout << endl; } } return 0; }