1011. A+B和C (15)

原题: 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

*/

posted @ 2017-10-17 14:31  阿胜4K  阅读(233)  评论(0编辑  收藏  举报