标签:int ring ever cas cst ase ace cin ios
#include <iostream> #include <cstring> #include <string> #include <cstdio> #include <algorithm> using namespace std; string bigmun(string a,string b){ string c; reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); char ans[2000]; int l=0,plus=0,i; char x[2000]; for(i=0;i<max(a.size(),b.size())-min(a.size(),b.size());i++){ x[i]=‘0‘; } x[i]=‘\0‘; string xx=x; if(a.size()<b.size()){ a=a+xx; } else{ b=b+xx; } for(i=0;i<min(a.size(),b.size());i++){ int x=a[i]-‘0‘; int y=b[i]-‘0‘; int z=x+y; z+=plus; plus=0; ans[l++]=z%10+‘0‘; plus+=z/10; } if(plus!=0){ ans[l++]=plus+‘0‘; } ans[l]=‘\0‘; c=ans; reverse(c.begin(), c.end()); return c; } int main(){ int n; scanf("%d",&n); int Case; Case=1; while (n--) { string a,b,c; cin>>a>>b; c=bigmun(a,b); printf("Case %d:\n",Case++); if(n!=0){ cout<<a<<" "<<"+"<<" "<<b<<" "<<"="<<" "<<c<<endl; cout<<endl; } else{ cout<<a<<" "<<"+"<<" "<<b<<" "<<"="<<" "<<c<<endl; } } return 0; }
标签:int ring ever cas cst ase ace cin ios
原文地址:https://www.cnblogs.com/xiao-xue-di/p/9454232.html