PAT——1011. A+B和C
给定区间[-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
package com.hone.basical; /**
* 分三个数组分别存放A B C 并且先将所有的数都存进去。
* 每次对应取出来,用减法做比较(目的是为了防止越界)然后做比较。
*/
import java.util.Scanner;
public class basicalLevel1011IsBigger2{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
long[]a = new long[T];
long[]b = new long[T];
long[]c = new long[T];
for(int i=0 ;i<T ;i++){
a[i] = sc.nextLong();
b[i] = sc.nextLong();
c[i] = sc.nextLong();
}
for(int i=0 ;i<T ;i++){
if(c[i]-b[i]<a[i]){
System.out.printf("Case #%d: true\n", i+1);
}
else{
System.out.printf("Case #%d: false\n", i+1);
}
}
}
}
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
https://pintia.cn/problem-sets/994805260223102976/problems/994805312417021952 给定区间[-2^31^, 2^31^]内的3 ...
- 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 ...
随机推荐
- 分布式事务概述--2pc的概念
转载自一个大拿:http://www.cnblogs.com/LBSer/p/4715395.html 前阵子从支付宝转账1万块钱到余额宝,这是日常生活的一件普通小事,但作为互联网研发人员的职业病,我 ...
- hdu 1561 树形背包 选k个最大价值
http://blog.csdn.net/dellaserss/article/details/8799730 这题其实和上一题思路是一样的,一个0节点作为根节点,通过剩余量来遍历子树. #inclu ...
- java 单例的实现及多线程下的安全
package com.demo01; public class Single { /** * 设计模式:单例设计模式 * 解决一个类中只允许存在一个对象这种情况: * 不允许通过类,无限制的创建该类 ...
- JS之setTimeOut与clearTimeOut
小练习1:针对HTML,分别使用 setTimeout 和 setInterval 实现以下功能: 点击按钮时,开始改变 fade-obj 的透明度,开始一个淡出(逐渐消失)动画,直到透明度为0 在动 ...
- 20个实用javascript技巧及实践(二)
21. 使用逻辑AND/OR来处理条件语句 var foo =10; foo ==10&& doSomething();// is the same thing as if (foo ...
- SQLServer导入大sql文件报错 对 COM 组件的调用返回了错误 HRESULT E_FAIL。 (mscorlib)
打开cmd执行(d:\script.sql为sql文件位置): sqlcmd -S 127.0.0.1 -U sa -P sa -i d:\script.sql From:https://ww ...
- php动态链接扩展库
文章来源:http://keping.me/php-call-so/ PHP调用C/C++动态链接库 David June 19, 2013 C++, Linux, Study 摘要 有时候,单纯依靠 ...
- Mysql与web之间的数据、查询等个问题
Mysql与web之间的数据.查询等个问题 在自己写的一个jsp主页连接数据库出现的各种问题,写记下来与大家分享,共勉.最后附jdbc代码. ---DanlV Error 1---错误代码: java ...
- Cookie实现留言板
Cookie实现留言板 直接代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content- ...
- CentOS 7运维管理笔记(2)----修改命令提示符颜色
使用 su 命令切换到root用户: 使用 vi /etc/bashrc 命令插入如下代码: PS1="[\e[1;32m\u\e[m\e[1;33m@\e[m\e[1;35m\h\e[m ...