题目出自 APCS 网站 > 历次试题 > 2016-10-29_实作题 > 第一题 三角形辨别
连结
解答仅供参考
解答:
#include <stdio.h>#include <stdlib.h>#include <algorithm>using namespace std;int main(void){ int side[3]; scanf("%d %d %d", &side[0], &side[1], &side[2]); sort(side, side + 3); int a = side[0]; int b = side[1]; int c = side[2]; printf("%d %d %d\n", a, b, c); if (a+b <= c) { printf("No"); } else if (a*a + b*b < c*c) { printf("Obtuse"); } else if (a*a + b*b == c*c) { printf("Right"); } else if (a*a + b*b > c*c) { printf("Acute"); } system("pause"); return 0;}
输入:
3 4 5
101 100 99
10 100 10
输出:
3 4 5Right
99 100 101Acute
10 10 100No