1065 A+B and C (64bit) (20 分)

1. 题目

Given three integers A, B and C in ((−2^{63},2^{63})), you are supposed to tell whether A+ B> C.

The first line of the input gives the positive number of test cases, T (≤10). Then T test cases follow, each consists of a single line containing three integers A, B and C, separated by single spaces.

For each test case, output in one line Case #X: true if A+ B> C, or Case #X: false otherwise, where X is the case number (starting from 1).

3
1 2 3
2 3 4
9223372036854775807 -9223372036854775808 0
Case #1: false
Case #2: true
Case #3: false

Thanks to Jiwen Lin for amending the test data.

2. 题意

输入a和b,判断a+b是否大于c。

3. 思路——简单模拟

4. 代码

方法1:

#include
#include

using namespace std;

typedef long long LL;

int main()
{
    LL n;
    LL a, b, c;
    cin >> n;
    for (int i = 1; i  0 && b > 0 && a + b < 0)
            cout << "Case #" << i << ": true" << endl;
        else if (a < 0 && b < 0 && a + b >= 0)
            cout << "Case #" << i << ": false" << endl;
        else if (a + b > c)
            cout << "Case #" << i << ": true" << endl;
        else cout << "Case #" << i << ": false" << endl;
    }
    return 0;
}

方法2:

#include

using namespace std;

typedef long long LL;s
typedef long double LD;

int main()
{
    LL n;
    LD a, b, c;
    cin >> n;
    for (int i = 1; i > a >> b >> c;
        if (a + b > c)
            cout << "Case #" << i << ": true" << endl;
        else
            cout << "Case #" << i << ": false" << endl;
    }
    return 0;
}

Original: https://www.cnblogs.com/vanishzeng/p/15478035.html
Author: vanish丶
Title: 1065 A+B and C (64bit) (20 分)

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/584700/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球