PTA-乙级1011 A+B 和 C (15 分)-JAVA

题意:题意很容易理解,有几个需要注意的地方,int取值范围是 [−231,231 -1],而题上的范围大于int,所以这里数据类型用long。
思路:1010的题解用的hasNext,这里我也就想到也可以用这个来实现边输入输出的操作(其实最开始我是想用三个数组来实现),
把三个数输入到内存中后就可以进项判断了,根据判断的不同输出结果即可。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//输入T个测试案例
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
//计数器
int count = 0;
while(sc.hasNext()) {
long A = sc.nextInt();
long B = sc.nextInt();
long C = sc.nextInt();
count++;
if(A+B>C) {
System.out.println("Case #"+count+": true");
} else {
System.out.println("Case #"+count+": false");
}
}
}
}