2012-01-18 15:18:08Morris
[JAVA] a021. 大數運算
import java.util.Scanner;
import java.io.IOException;
import java.math.BigInteger;
public class a021 {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
String input;
while(cin.hasNext()) {
input = cin.nextLine();
String[] cut = input.split(" ");
BigInteger x, y;
x = new BigInteger(cut[0]);
y = new BigInteger(cut[2]);
if(cut[1].charAt(0) == '+') {
x = x.add(y);
} else if(cut[1].charAt(0) == '-') {
x = x.subtract(y);
} else if(cut[1].charAt(0) == '*') {
x = x.multiply(y);
} else
x = x.divide(y);
System.out.println(x);
}
}
}
import java.io.IOException;
import java.math.BigInteger;
public class a021 {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
String input;
while(cin.hasNext()) {
input = cin.nextLine();
String[] cut = input.split(" ");
BigInteger x, y;
x = new BigInteger(cut[0]);
y = new BigInteger(cut[2]);
if(cut[1].charAt(0) == '+') {
x = x.add(y);
} else if(cut[1].charAt(0) == '-') {
x = x.subtract(y);
} else if(cut[1].charAt(0) == '*') {
x = x.multiply(y);
} else
x = x.divide(y);
System.out.println(x);
}
}
}
下一篇:[JAVA] a104. 排序