用java写大数,感觉就是BUG
1 import java.math.*; 2 import java.io.*; 3 import java.util.*; 4 public class Main{ 5 public static void main(String[] args){ 6 Scanner sc = new Scanner(System.in); 7 BigDecimal f1, f2; 8 int c = Integer.parseInt(sc.next()); 9 int i = 1; 10 while(sc.hasNext()){ 11 12 f1 = new BigDecimal(sc.next()); 13 f2 = new BigDecimal(sc.next()); 14 System.out.println("Case " + i + ":"); 15 System.out.println(f1 + " + " + f2 + " = " + f1.add(f2) ); 16 if(i < c) 17 System.out.println(); 18 //System.out.println(f1.subtract(f2)); 19 //System.out.println(f1.multiply(f2)); 20 //System.out.println(f1.divide(f2)); 21 i++; 22 if(i > c) break; 23 } 24 25 } 26 }