急急急!CPP高精度怎么错了???急急急!!!

来源:百度知道 编辑:UC知道 时间:2024/05/29 12:34:21
#include <iostream>
using namespace std;
int main ()
{
string str1,str2;
int a[250],b[250],len;
int i;

scanf("%s %s",&str1,&str2);
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for (int i = 1;i <= a[0];i++) a[i] = str1[a[0]-i]-'0';
{a[0] = str1.length();}

for (int i = 1;i <= b[0];i++) b[i] = str2[b[0]-i]-'0';
{b[0] = str2.length();}

len = (a[0]>b[0]?a[0]:b[0]);

for (int i =1;i <= len;i++)
{
a[i]+=b[i];
a[i+1]+=a[i]/10;
a[i]%=10;
}
len ++;

while ((a[len]==0)&&(len>1)) len--;

for (int i = len;i >=1;i--) printf("%d",a[i]);

system("PAUSE");
return 0;
}

麻烦了......
哎...
自己写得代码自己总查不出来错......
不要标程,要查错... wo觉得是scanf(“%s %s”,&str1,&str2);错了......

哪个老师教的?
char str1[300],str2[300];
然后
scanf("%s",str1);
scanf("%s",str2);

接着
str1[i]=str1[i]+str2[i]-'\0'+进位;
if(str1[i]>'\9') 进位=1 else 进位=0;

要标程么?c++