PAT乙级1011

题目链接

https://pintia.cn/problem-sets/994805260223102976/problems/994805312417021952

题解

很明显这题是考数值范围的,int占4个字节,范围正好是$ [−2{31},2]$。

两个大的int相加会溢出,而long只保证不比int的位数少,所以使用long long较好。

// PAT BasicLevel 1011
// https://pintia.cn/problem-sets/994805260223102976/problems/994805312417021952

#include <iostream>
using namespace std;

int main()
{
    // 获取测试用例个数
    int t;
    cin >>t;

    // 三个整数
    long long  a,b,c;



    for(int i=1;i<=t;i++){
        cin >> a >> b >> c;
        cout << "Case #"<< i <<": " << (a + b > c ? "true" : "false")<< endl;
    }


    system("pause");
    return 0;
}

作者:@臭咸鱼

转载请注明出处:https://www.cnblogs.com/chouxianyu/

欢迎讨论和交流!


posted @ 2019-08-04 23:47  臭咸鱼  阅读(177)  评论(0编辑  收藏  举报