当前位置:网站首页>PAT 乙等 1011 C语言
PAT 乙等 1011 C语言
2022-06-23 04:11:00 【章鱼bro】
1011. A+B和C (15)
给定区间[-231, 231]内的3个整数A、B和C,请判断A+B是否大于C。
输入格式:
输入第1行给出正整数T(<=10),是测试用例的个数。随后给出T组测试用例,每组占一行,顺序给出A、B和C。整数间以空格分隔。
输出格式:
对每组测试用例,在一行中输出“Case #X: true”如果A+B>C,否则输出“Case #X: false”,其中X是测试用例的编号(从1开始)。
输入样例:4 1 2 3 2 3 4 2147483647 0 2147483646 0 -2147483648 -2147483647输出样例:
Case #1: false Case #2: true Case #3: true Case #4: false
思路:直接判断即可,注意因为过程中可能会超出int的取值范围,故使用long int声明变量
代码:
#include "stdio.h"
int main(){
int x;
long int a,b,c;
int i;
scanf("%d",&x);
for(i = 0; i < x; i++)
{
scanf("%ld",&a);
scanf("%ld",&b);
scanf("%ld",&c);
if(a + b > c)
{
printf("Case #%d: true\n",i + 1);
}else
{
printf("Case #%d: false\n",i + 1);
}
}
return 0;
} 边栏推荐
- Wechat applet: future wife query generator
- True question of MySQL interview (29) -- case - finding favorite movies
- Win software - (net framework) processed the certificate chain but terminated in a root certificate that is not trusted by the trusted provider
- MySQL面试真题(二十五)——常见的分组比较场景
- STC 32 Bit 8051 Single Chip Computer Development Example Tutorial one development environment
- MySQL面试真题(二十三)——拼多多-球赛分析
- Wechat applet: an artifact for calculating the full amount of orders
- 电脑开机显示器黑屏是什么原因,电脑显示器黑屏怎么办
- Facing new challenges and becoming a better self -- an advanced technology er
- 数字藏品市场才刚刚开始
猜你喜欢

A bit of knowledge - folding forging and Damascus steel

Database connection exception: create connection error, url: jdbc: mysql://ip/ Database name, errorcode 0, state 08s01 problem handling

MySQL面试真题(二十七)——RFM分析法对用户进行分类

jvm: 方法重载时,具体调用哪个方法,是由传入参数的静态类型来决定的,而不是由参数的实际类型来决定

MySQL面试真题(三十)——贝壳-房产订单分析

MySQL面试真题(二十三)——拼多多-球赛分析

Heimdall Database Proxy横向扩展提高20倍

Differences between fs4059a and fs5080e charging chips

The performance of nonstandard sprintf code in different platforms

Visdom draws multiple dynamic loss curves
随机推荐
Build a gocd environment
Jvm: when a method is overloaded, the specific method to call is determined by the static type of the incoming parameter rather than the actual type of the parameter
Composite API
Shutdown shutdown command
FS2119A同步升压IC输出3.3V和FS2119B同步升压IC输出5V
树莓派assert初步使用练习
Win11 app store keeps turning around solution
Wechat applet: elderly blessing short video
MySQL面试真题(二十二)——表连接后的条件筛选及分组筛选
MySQL面试真题(二十一)——金融-贷款逾期
About replay attack and defense
How does win11 enable mobile hotspot? How to enable mobile hotspot in win11
visdom的使用
ssm项目搭建
Current situation and development of containerization technology under the cloud native trend
Face recognition determination threshold
The performance of nonstandard sprintf code in different platforms
WebRTC[47] - WebRTC 保存 YUV 数据的常用方式
104. simple chat room 7: use socket to transfer objects
Win11应用商店一直转圈解决办法