package Exercises;
import java.util.Arrays;
import java.util.Scanner;
/**
* 大数字之和, 字符串-字符数组实现
* 2020 07 12
*/
public class TheSumOfLargeNumbers {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s1 = in.nextLine();
String s2 = in.nextLine();
System.out.println(s1);
System.out.println(s2);
System.out.println(add(s1,s2));
}
public static String add(String s1, String s2){
if (s1 == null||s2==null) {
return "null";
}
char[] arr1=s1.length()>s2.length()?s1.toCharArray():s2.toCharArray();
char[] arr2=s1.length()>s2.length()?s2.toCharArray():s1.toCharArray();
int l=arr1.length+1;
int[] sum=new int[l];
StringBuilder result = new StringBuilder();
char t;//将char类型的ascli码转为int只需要 -'0'
for (int i = 0; i < arr1.length; i++) {
sum[i]=arr1[arr1.length-1-i]-'0';
}
for (int i = 0; i < arr2.length; i++) {
sum[i]+=arr2[arr2.length-1-i]-'0';
}
for (int i = 0; i < l; i++) {
if (sum[i]>9) {
sum[i]-=10;
sum[i+1]++;
}
}
boolean flag=false;
for (int i = sum.length-1; i >=0; i--) {
if (sum[i]!=0) {
flag=true;
}
if(flag){
result.append(sum[i]);
}
}
return result.toString();
}
}