文章
47
粉丝
109
获赞
8
访问
29.7k
#include<stdio.h>
int main() {
int x = 0;
scanf("%d", &x);
while (x--) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
//a定为最大的,b定为中等的,c定位最小的
if (a < b) {
int tmp = a;
a = b;
b = tmp;
}
if (a < c) {
int tmp = a;
a = c;
c = tmp;
}
if (b < c) {
int tmp = b;
b = c;
c = tmp;
}
int cnt = 0;
if ((a + b > c && a - b < c) && (a + c > b && a - c < b) && (b + c > a && b - c < a))
{
if (a * a > b * b + c * c)
{
cnt = 3;
}
else if (a * a == b * b + c * c)
{
cnt = 2;
}
else if (a * a < b * b + c * c)
{
cnt = 1;
}
}
else {
cnt = -1;
}
printf("%d\n", cnt);
}
return 0;
}
第二种,复杂的
#include<stdio.h>
int main() {
int n;
scanf("%d", &n);
int s[3] = {0};
while (n--) {
for (int i = 0; i < 3; i++) {
scanf("%d", &s[i]);
...
登录后发布评论
暂无评论,来抢沙发