PAT 乙级 1011

题目

    题目地址:PAT 乙级 1011

 

思路

    这道题的比较坑的地方在于给定数据的范围

    int 类型的数据大小是[-2^31 , 2^31 -1] 即 [-2147483648,2147483647]

    本题给定数据的大小是[-2^31 , 2^31]正好比int类型的正数多了1,因此需要改变数据类型,扩大数能表示的范围

 

代码

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int main() {
 5     int t = 0;
 6     long long a = 0, b = 0, c = 0;
 7     cin >> t;
 8     int cnt = 1;
 9     while (t--) {
10         cin >> a >> b >> c;
11         if (a + b > c)
12             cout << "Case #" << cnt << ": true" << endl;
13         else
14             cout << "Case #" << cnt << ": false" << endl;
15         cnt++;
16     }
17 
18     return 0;
19 }

 

posted @ 2018-07-20 11:26  moujun  阅读(174)  评论(0编辑  收藏  举报