C++與演算法

解答 - 三角形邊長

作法就在題目中:

任挑其中兩根木條長度和都大於第三根木條時,那這三根木條也一定能拼一個三角形

因此列出所有任挑兩條的狀況,每一種狀況能大於第三邊時,就輸出Yes

#include<iostream>
using namespace std;

int main()
{
    int a, b, c;

    while( cin >> a >> b >> c )
    {
        if( a+b>c and a+c>b and b+c>a )
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}