高精度加法,相当于a+b problem,不用考虑负数.
输入格式分两行输入。a,b≤10^500。
输出格式输出只有一行,代表a+b的值。
#include#include using namespace std; int main() { string str1,str2; cin>>str1>>str2; //输入两个数字,并用字符串存储 int len1=str1.length(); int len2=str2.length(); string str; int i; if(len1 =0;i--) { temp=str1[i]-'0'+str2[i]-'0'+cf; //将字符串每个对应位置的数字相加 cf=temp/10; //确定十进制应该进的数字 temp%=10; str=char(temp+'0')+str; //将每次求得的数字发在最前面 } if(cf!=0) //如果cf不为零,代表该数字应该增加一位 str=char(cf+'0')+str; cout<



