学习一下高精度计算系列
y总好帅爱了爱了
有输入输出
import java.util.*;
public class Main{
public static String sum(List<Integer> a,List<Integer> b) {
int[] c = new int[100010];
int t = 0,i;
for(i = 0;i < a.size() || i < b.size(); i ++) {
if(i < a.size()) c[i] = t += a.get(i);
if(i < b.size()) c[i] = t += b.get(i);
c[i] = t % 10;
t = t/10;
}
if(t > 0) c[i] = t;
while(i >= 1 && c[i] == 0) i --;
StringBuilder stb = new StringBuilder();
for(int j = i; j >= 0; j --) {
stb.append(c[j]);
}
return stb.toString();
}
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.nextLine();
String b = sc.nextLine();
List<Integer> A =new ArrayList<>(a.length());
List<Integer> B =new ArrayList<>(b.length());
for(int i = a.length() - 1;i >= 0;i --) {
A.add(a.charAt(i) - '0');
}
for(int i = b.length() - 1;i >= 0;i --) {
B.add(b.charAt(i) - '0');
}
System.out.print(sum(A,B));
}
}