| ||||||||||
| 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 | |||||||||
老runtime error,诡异#include<stdio.h>
int f[10];
int count(int x)
{
int i,a,s,t,d,total=0;
if(x>0)d=1;else{d=-1;x=-x;}
a=x;t=1;s=0;
while(a/10){t*=10;a/=10;s++;}
for(i=1;i<10;i++)f[i]+=a*s*d*t/10;
for(i=1;i<a;i++)f[i]+=t*d;
f[a]+=(x%t+1)*d;
if(x-x/t*t)count((x-x/t*t)*d);
t=1;
for(i=1;i<=s;i++){total+=9*t*i;t*=10;}
total+=(x-t+1)*(s+1);
return total;
}
int main()
{
int i,m,a,b,zero;
while(scanf("%d%d",&a,&b),a)
{
for(i=1;i<10;i++)f[i]=0;
if(a>b){m=a;a=b;b=m;}
zero=count(b);
if(a>1)zero-=count(1-a);
for(i=1;i<10;i++)zero-=f[i];
f[0]=zero;
for(i=0;i<9;i++)printf("%d ",f[i]);
printf("%d\n",f[9]);
}
return 0;
}
这个代码RE,但把f放到函数里面写成count(int f[],int x)就能AC。哪个高手能告诉我为什么?!
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator