PAT 1011 A+B和C
https://pintia.cn/problem-sets/994805260223102976/problems/994805312417021952
给定区间[-2^31^, 2^31^]内的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
代码:
#include <bits/stdc++.h> using namespace std; int sum(long long int a,long long int b,long long int c)
{
if(a+b>c)
return 1;
else
return 0;
} int main()
{
int T;
scanf("%d",&T);
for(int i=1;i<=T;i++)
{
long long int A,B,C;
scanf("%lld%lld%lld",&A,&B,&C);
cout<<"Case #"<<i<<": ";
if(sum(A,B,C)==1)
cout<<"true"<<endl;
else
cout<<"false"<<endl;
}
return 0;
}
PAT 1011 A+B和C的更多相关文章
- PAT 1011
1011. World Cup Betting (20) With the 2010 FIFA World Cup running, football fans the world over were ...
- PAT 1011 World Cup Betting
1011 World Cup Betting (20 分) With the 2010 FIFA World Cup running, football fans the world over w ...
- PAT 1011 A+B和C (15)(C++&JAVA&Python)
1011 A+B和C (15)(15 分) 给定区间[-2^31^, 2^31^]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个 ...
- pat 1011 World Cup Betting(20 分)
1011 World Cup Betting(20 分) With the 2010 FIFA World Cup running, football fans the world over were ...
- PAT 1011. A+B和C (15)
给定区间[-231, 231]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个数.随后给出T组测试用例,每组占一行,顺序给出A.B ...
- 浙大pat 1011题解
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- PAT——1011. A+B和C
给定区间[-231, 231]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个数.随后给出T组测试用例,每组占一行,顺序给出A.B ...
- PAT 1011 World Cup Betting 查找元素
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- PAT 1011 World Cup Betting (20分) 比较大小难度级别
题目 With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly exc ...
随机推荐
- BZOJ 1444:[JSOI2009]有趣的游戏
BZOJ 1444:[JSOI2009]有趣的游戏 题目链接 首先我们建出Trie图,然后高斯消元. 我们设\(f_i\)表示经过第\(i\)个点的期望次数: \[ f_x=\sum i\cdot p ...
- c++のurlmon实现下载文件并进度回调
主文件: #include "stdafx.h" #include <UrlMon.h> #pragma comment(lib, "urlmon.lib&q ...
- python之面向对象进阶3
1.isinstace和issubclass 2.staticmethod和classmethod 3.反射(hasattr.getattr.setattr.delattr等四个方法) 4.内置方法 ...
- socket.io+angular.js+express.js做个聊天应用(三)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/www19940501a/article/details/27590611 接着前面博客文章socke ...
- salt-api安装与配置
一,安装部分[root@LCB-U-syng01 ~]#wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz#md5= ...
- win10搭建ftp服务器的操作方法【图文教程】
我们知道FTP是TCP/IP网络上两台计算机传送文件的协议,使得主机间可以共享文件.对于win10版本的ftp服务器搭建方法可能有部分用户还不是很清楚,下面这篇文章就是关于win10搭建ftp服务器的 ...
- PCB (2)创建新工程原理图
1创建一个新项目 2创建一个新的原理图图纸 3将原理图图纸添加到项目 4设置原理图选项 修改单位 设置图纸大小 图纸附加说明 5绘制原理图 打开库 之后连续放置的器件会在此基础上+1 名字 描述 6 ...
- python3 用户登录 day01
'''用户登录作业需求:1. 三次重试机会2. 每次输错误时显示剩余错误次数'''num = 1while num <= 3: username = input("请输入用户名:&qu ...
- ubuntu16.04安装配置nagios
参考博文:https://www.howtoing.com/ubuntu-nagios/ 该博文真实有效可供参考,按照步骤,基本可以成功 一.安装的先决条件 sudo apt-get install ...
- nohup: failed to run command `java': No such file or directory
在执行脚本添加这一行 source /etc/profile exec nohup java -Xms1024m -Xmx2048m -jar /opt/dev/claimzuul/$JAR_BAO ...