PAT B1011 [A + B] and C

PAT B1011 [A + B] and C

Given interval [-2 ^ 31, 2 ^ 31] three integers A, B and C in, please determines whether A + B is greater than C.
Input format:
Enter line 1 gives a positive integer T (<= 10), a number of test cases. T is then given set of test cases, each per line, the order is given A, B and C. Between integer separated by a space.
Output format:
for each test case, the output in line "Case #X: true" if A + B> C, and otherwise outputs "Case #X: false", where X is the test case number (starting from 1).
Sample input: 4
. 1. 3 2
2. 4. 3
2147483647 2147483646 0
0-2147483648 -2147483647
Output Sample:
Case #. 1: to false
Case # 2: to true
Case #. 3: to true
Case #. 4: to false

#include <stdio.h>

int main() {
    int num, time = 1;
    long long a, b, c;
    scanf("%d", &num);
    while (num--) {
        scanf("%lld%lld%lld", &a, &b, &c);
        if (a + b > c) {
            printf("Case #%d: true\n", time);
        } else
            printf("Case #%d: false\n", time);
        time++;
    }
    return 0;
}
/*测试数据
4
1 2 3
2 3 4
2147483647 0 2147483646
0 -2147483648 -2147483647

 */

Test Results:
Here Insert Picture Description

Published 33 original articles · won praise 1 · views 4160

Guess you like

Origin blog.csdn.net/qq_39827677/article/details/103855199