Problem Description
小明這學期的數學課教到了三角形,於是老師給了他們一個作業,這個星期一到星期五每個人上學時都要帶三根樹枝到學校來,如果那三根樹枝可以構成一個三角形,那天就可以加一分。給你小明所帶樹枝的長度,請你幫他看看他可以加幾分?
Input Format
輸入一共有 5 行,每行有 3 個整數,代表當天小明所帶的樹枝的長度。
Output Format
輸出一個整數,代表小明可以加幾分。
Sample Input
1 2 3
2 4 6
3 4 5
5 3 2
1 3 5
Sample Output
1
-----*Problem from【ZeroJudge, An Online Judge System For Beginners】
My Answer
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. |
#include<iostream> using namespace std; int main(void) { int a, b, c; int count=0; for(int i=0; i<5; ++i){ cin>>a>>b>>c; if(a+b>c && a+c>b && c+b>a) count++; } cout<<count<<endl; return 0; } |
全站熱搜