标签:|| strlen cin tmp col pre for class ++
char a[maxn],b[maxn]; char c[maxn]; cin>>a; cin>>b; int k=0,tmp=0; int lena=strlen(a)-1,lenb=strlen(b)-1; while(lena>=0||lenb>=0) { int res=0; if(lena>=0) res+=a[lena]-‘0‘; if(lenb>=0) res+=b[lenb]-‘0‘; res+=tmp; c[k++]=(res%10+‘0‘); tmp=res/10; lena--,lenb--; } while(tmp) { c[k++]=tmp%10+‘0‘; tmp/=10; } for(int i=k-1;i>=0;i--) cout<<c[i];
标签:|| strlen cin tmp col pre for class ++
原文地址:https://www.cnblogs.com/wronin/p/11422432.html