给定区间[-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的更多相关文章

  1. PAT 1011

    1011. World Cup Betting (20) With the 2010 FIFA World Cup running, football fans the world over were ...

  2. PAT 1011 World Cup Betting

    1011 World Cup Betting (20 分)   With the 2010 FIFA World Cup running, football fans the world over w ...

  3. 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),是测试用例的个 ...

  4. pat 1011 World Cup Betting(20 分)

    1011 World Cup Betting(20 分) With the 2010 FIFA World Cup running, football fans the world over were ...

  5. PAT 1011. A+B和C (15)

    给定区间[-231, 231]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个数.随后给出T组测试用例,每组占一行,顺序给出A.B ...

  6. 浙大pat 1011题解

    With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...

  7. PAT 1011 A+B和C

    https://pintia.cn/problem-sets/994805260223102976/problems/994805312417021952 给定区间[-2^31^, 2^31^]内的3 ...

  8. PAT 1011 World Cup Betting 查找元素

    With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...

  9. PAT 1011 World Cup Betting (20分) 比较大小难度级别

    题目 With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly exc ...

随机推荐

  1. Oracle中Merge into的用法实例讲解

    最近在做一个需求,就是涉及到表的问题,前端传过来一条数据,根据主键,查询数据库,如果不存在,那么久插入到数据库中一条,如果存在的话,就是以主键的方式,对数据库中的数据,进行更新. 拿到这个需求的时候, ...

  2. centos top 命令详解及退出top命令-使用p键及free命令

    1.作用 top命令用来显示执行中的程序进程,使用权限是所有用户. 2.格式 top [-] [d delay] [q] [c] [S] [s] [i] [n] 3.主要参数 d:指定更新的间隔,以秒 ...

  3. springMVC基于注解的控制器

    springMVC基于注解的控制器 springMVC基于注解的控制器的优点有两个: 1.控制器可以处理多个动作,这就允许将相关操作写在一个类中. 2.控制器的请求映射不需要存储在配置文件中.使用re ...

  4. Python中@修饰符的作用。

    '@'符号用作函数修饰符是python2.4新增加的功能,修饰符必须出现在函数定义前一行,不允许和函数定义在同一行.也就是说@A def f(): 是非法的. 只可以在模块或类定义层内对函数进行修饰, ...

  5. java 单例的实现及多线程下的安全

    package com.demo01; public class Single { /** * 设计模式:单例设计模式 * 解决一个类中只允许存在一个对象这种情况: * 不允许通过类,无限制的创建该类 ...

  6. JavaScript里面的居民们1-数据

    编码 首先练习数字相关的一些操作: <div> <label>Number A:<input id="radio-a" type="radi ...

  7. JavaScript this指向相关内容

    1,默认绑定this指向windw对象 看代码: function test(C){ var a = 123 function b(){}; } 在预编译环节当中. OA{ arguments:[1] ...

  8. Unity创建或克隆对象 Instantiate()

    //需要创建对象 GameObject prefab; //创建对象的规定位置或父物体 Transform tr; //创建出对象 Instantiate(prefab); //创建对象,并设定位置和 ...

  9. 求n的元素的最大最小值

    public static int[] maxMin(int a[]) { int[] res = new int[2]; int len = a.length; if (len <= 0) { ...

  10. Excel 函数使用

    字符串 20180613 转为日期  2018-06-13,单元格内输入如下公式 =DATE(LEFT(),MID(,),RIGHT()) IF 函数内的或.与 =IF(AND(A=B,C=D),&q ...