大数想加的代码及用法:
#include<iostream>
#include<string>
using namespace std;
int n=0;
string jia(string a,string b,int as,int bs)
{
char c;
int i,j;
for(i=as-1,j=bs-1;j>=0;i--,j--)
{
c=(a[i]+b[j]-96+n)%10+48;
if(a[i]+b[j]+n-96>9)
n=1;
else
n=0;
a[i]=c;
}
for(;i>=0;i--)
{
c=(a[i]-48+n)%10+48;
if(a[i]+n-48>9)
n=1;
else
n=0;
a[i]=c;
}
return a;
}
int main ()
{
int as,bs,sd,sc,q,j,i;
string a,b;
cin>>a>>b;
as=a.size(),bs=b.size();
if (as>bs)
{
a=jia(a,b,as,bs);
if(n)
cout<<n;
cout<<a;
}
else
{
b=jia(b,a,bs,as);
if(n)
cout<<n;
cout<<b;
}
}