您的位置:首页 > 其它

1011. A+B和C (15)

2017-10-17 14:31 211 查看

原题: https://www.patest.cn/contests/pat-b-practise/1011

题目本身非常简单, 但有个小坑. 就是需要使用

long int
, 而且看样子PAT提供的
编译器(gcc4.7.2), 使用scanf获取
long int
的值时, 需要使用
%ld

完整实现:

#include <stdio.h>

int main () {
int t;
long int a;
long int b;
long int c;
int i = 0;

scanf("%d", &t);
while (t != 0) {
scanf("%ld", &a);
scanf("%ld", &b);
scanf("%ld", &c);
i = i + 1;
if (a + b > c) {
printf("Case #%d: true\n", i);
} else {
printf("Case #%d: false\n", i);
}
t = t - 1;
}
return 0;
}

/*
input:
4
1 2 3
2 3 4
2147483647 0 2147483646
0 -2147483648 -2147483647

output:
Case #1: false
Case #2: true
Case #3: true
Case #4: false

*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: