| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
不知道错在哪里,找了很多测试数据都通过了,就是wrong answer!求指导!!!#include<stdio.h>
#include<string.h>
char *fun(char *a,char *b,char *c)//计算任意大三个数的和
{
int i,j,up,x,y,l,z,L1,L2,L3;
char d[104],s[104];
L1=strlen(a);L2=strlen(b);L3=strlen(c);
i=0;j=0;up=0;
while(L1>0||L2>0||L3>0)
{
if(L1<=0) x=0;else x=a[L1-1]-'0';
if(L2<=0) y=0;else y=b[L2-1]-'0';
if(L3<=0) l=0;else l=c[L3-1]-'0';
z=x+y+l+up;
if(z>9)
{
if(z>=10&&z<20) up=1;
if(z>=20) up=2;
z=z%10;
}
else up=0;
d[i++]=z+'0';
L1--;L2--;L3--;
}
if(up==1) d[i++]='1';
if(up==2) d[i++]='2';
d[i]='\0';
for(j=0;j<i;j++)
s[j]=d[i-j-1];
s[j]='\0';
return s;
}
main()
{
int i;
char a[104],b[104],c[104],*d;
freopen("D:\\aa.txt","r",stdin);
while(scanf("%s%s%s",a,b,c)!=EOF)
{
for(i=3;i<=99;i++)//循环求出A99
{
d=fun(a,b,c);
strcpy(a,b);
strcpy(b,c);
strcpy(c,d);
}
printf("%s\n",d);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator