题目描述
C++解法
解法1
#include<cstdio>
#include<cstring>
using namespace std;
int main() {
int T, tcase = 1;
scanf("%d", &T);
while (T--) {
long long a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
if (a + b > c) {
printf("Case #%d: true\n", tcase++);
}
else {
printf("Case #%d: false\n", tcase++);
}
}
return 0;
}
解法2
#include <iostream>
using namespace std;
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
long long int a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
printf("Case #%d: %s\n", i + 1, a + b > c ? "true" : "false");
}
return 0;
}
python解法
N = int(input())
for i in range(N):
a, b, c = tuple(map(int,input().split()))
if a+b > c:
print("Case #{}: true".format(int(i+1)))
else:
print("Case #{}: false".format(int(i+1)))
python牛逼
不过做算法最好用C++