1011-A+B和C
leenickzh Lv4

给定区间[−,]内的3个整数A,BC,请判断A+B是否大于C.

输入格式

输入第1行给出正整数T (≤10),是测试用例的个数.随后给出T组测试用例,每组占一行,顺序给出A,BC.整数间以空格分隔.

输出格式

对每组测试用例,在一行中输出Case #X: true如果 A+B>C,否则输出Case #X: false,其中X是测试用例的编号(从1开始).

输入样例

1
2
3
4
5
4
1 2 3
2 3 4
2147483647 0 2147483646
0 -2147483648 -2147483647

输出样例

1
2
3
4
Case #1: false
Case #2: true
Case #3: true
Case #4: false

分析

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <string>
using namespace std;

int main()
{
int TestNum = 0;
cin>>TestNum;
if(TestNum<1||TestNum>10)
{
return 0;
}
long long A,B,C;
bool cases[10];
string bools[2] = {"false","true"};
for(int i = 0;i < TestNum; i++)
{
cin>>A>>B>>C;
if(A+B>C)
{
cases[i] = true;
}else
{
cases[i] = false;
}
}
for(int i = 0;i < TestNum; i++)
{
cout<<"Case #"<<i+1<<": "<<bools[cases[i]]<<endl;
}
return 0;
}
  • Post title:1011-A+B和C
  • Post author:leenickzh
  • Create time:2021-04-13 22:12:04
  • Post link:https://nickk.cn/2021/04/13/1011-A-B和C/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
 Comments