void char_add(char* a,char* b,char* c)
{
int ia[max]={0};
int ib[max]={0};
int ic[max]={0};
int flag=0;
int i,tmp,tmp2;
for(i=0;i<max;i++)
{
if(a[i]=='\0') ia[i]='0'; else ia[i]=a[i]-'0';
if(b[i]=='\0') ib[i]='0'; else ib[i]=b[i]-'0';
}
for(i=max-1;i>=0;i--)
{
tmp=ia[i]+ib[i];
flag=tmp/10;
tmp2=ic[i]+tmp%10;
if(tmp2>=10) {flag=1; ic[i]=tmp2%10;} else ic[i]=tmp2;
if(i>0) ic[i-1]=flag;
}
for(i=0;i<max;i++) c[i]=ic[i]+'0';
}
int main()
{
clock_t start,finish;
start=clock();
char a[max]={'\0'};
char b[max]={'\0'};
char c[max]={'\0'};
int i,j;
for(i=0;i<max;i++)
{
a[i]='0';
b[i]='0';
c[i]='0';
}
a[max-1]='1';
b[max-1]='1';
j=0;
while(j<482)
{
char_add(a,b,c);
for(i=0;i<max;i++)
{
a[i]=b[i];
b[i]=c[i];
}
j++;
c[max]='\0';
printf("%s\n",c);
}
c[max]='\0';
//printf(" Fibonacci数列中第一百个是%s\n",c);
finish=clock();
printf("计算Fibonacci数列共耗时%.3lf秒",((double)finish-start)/1000);
return 0;
}