UVa 11479 - Is this the easiest problem?

来源:互联网 发布:海豚加速器for mac 编辑:程序博客网 时间:2024/06/07 07:12

题目:给出三角形三边判断所属集合。

分析:简单题。直接判断即可。

注意:数据可能有负数、使用long long类型。

#include <iostream>#include <cstdlib>#include <cstdio>using namespace std;int main(){int t;long long a,b,c;while ( cin >> t )for ( int i = 1 ; i <= t ; ++ i ) {cin >> a >> b >> c;printf("Case %d: ",i);if ( a > 0 && a == b && b == c )printf("Equilateral\n");else if ( a > 0 && b > 0 && c > 0 ) { if ( a == b && a+b > c || b == c && b+c > a || a == c && a+c > b )printf("Isosceles\n");else if ( a+b <= c || a+c <= b || b+c <= a )printf("Invalid\n");else printf("Scalene\n");}else printf("Invalid\n");}    return 0;}