a b和c 15 java_1011. A+B和C (15)
給定區(qū)間[-231, 231]內(nèi)的3個整數(shù)A、B和C,請判斷A+B是否大于C。
輸入格式:
輸入第1行給出正整數(shù)T(<=10),是測試用例的個數(shù)。隨后給出T組測試用例,每組占一行,順序給出A、B和C。整數(shù)間以空格分隔。
輸出格式:
對每組測試用例,在一行中輸出“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
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
while (cin.hasNext()) {
int t = cin.nextInt();
for (int i = 1; i <= t; i++) {
boolean flag = false;
BigInteger a = cin.nextBigInteger();
BigInteger b = cin.nextBigInteger();
BigInteger c = cin.nextBigInteger();
if (a.add(b).compareTo(c) > 0) {
flag = true;
}
System.out.println("Case #" + i + ": " + flag);
}
}
}
}#include
using namespace std;
int main() {
int n, i;
long a, b, c, sum;
while(cin>>n) {
i = 1;
while(n--) {
cin>>a>>b>>c;
sum = a+ b;
if(sum > c) {
cout<
} else {
cout<
}
}
}
return 0;
}
總結(jié)
以上是生活随笔為你收集整理的a b和c 15 java_1011. A+B和C (15)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java定位线程阻塞_Arthas -
- 下一篇: dos命令查看oracle_home,O