提交时间:2024-05-05 17:29:54
运行 ID: 145837
#include<bits/stdc++.h> #define int long long using namespace std; int a1[5001],b1[5001],c[5001]; signed main(){ char a[5001],b[5001]; cin>>a>>b; int len1=strlen(a); int len2=strlen(b); for(int i=1;i<=len1;i++){ a1[i]=a[len1-i]-'0'; } for(int i=1;i<=len2;i++){ b1[i]=b[len2-i]-'0'; } int len3=1; int x=0; while(len3<=len1||len3<=len2){ c[len3]=a1[len3]+b1[len3]+x; x=c[len3]/10; c[len3]%=10; len3++; } c[len3]=x; while(c[len3]==0&&len3>1){ len3--; } for(int i=len3;i>=1;i--){ cout<<c[i]; } return 0; }