【題目敘述】https://zerojudge.tw/ShowProblem?problemid=e614
【解題想法】
- 三角形的三邊長關係:三角形任意兩邊長的和大於第三邊,任意兩邊長之差的絕對值小於第三邊。
- 三邊長先排序,判斷兩個短邊長的和大於第三邊即可。
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int T, a[3];
cin >> T;
while (T--){
cin >> a[0] >> a[1] >> a[2];
sort(a, a+3);
if (a[0] + a[1] > a[2]) cout << "OK\n";
else cout << "Wrong!!\n";
}
return 0;
}