| ||||||||||
| 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 | |||||||||
在某些情况下,找找数据也不是太……In Reply To:求助。。。。。。。。。。。考虑了,开始为0的情况。。。调了一天了,不能在弄下去了。。点化一下,,,不胜感激呀!! Posted by:SilenceIowyh at 2005-08-12 20:49:48 > #include<stdio.h>
> #include<string.h>
>
>
> int com(char a[],char b[])
> {
> int m,n,k;
> for(m=0;a[m]!='\0';m++);
> for(n=0;b[n]!='\0';n++);
> if(m<n) return 0;
> if(m==n)
> {
> for(k=m-1;k>=0;k--)
> {
> if(a[k]<b[k])
> return 0;
> if(a[k]>b[k])
> return 1;
> }
> if(k==-1) return 1;
> }
> if(m>n) return 1;
> }
>
>
> void main()
> {
> char fib[480][120];
> char s1[120],s2[120],s3[120],s4[120];
> int i,j,count,c,d;
>
> strcpy(fib[0],"1");
> strcpy(fib[1],"2");
> for(i=2;i<480;i++)
> {
> strcpy(s1,fib[i-1]);
> for(j=0;fib[i-2][j]!='\0';j++)
> s1[j]+=(fib[i-2][j]-'0');
>
> for(j=0;s1[j+1]!='\0';j++)
> if(s1[j]>=(10+'0'))
> {
> s1[j+1]+=(int)(s1[j]-'0')/10;
> s1[j]=(int)(s1[j]-'0')%10+'0';
> }
>
> if(s1[j]>=(10+'0'))
> {
> s1[j+2]='\0';
> s1[j+1]=(int)(s1[j]-'0')/10+'0';
> s1[j]=(int)(s1[j]-'0')%10+'0';
> }
>
> strcpy(fib[i],s1);
>
> }
> while(1)
> {
> scanf("%s%s",s3,s4);
> if(strcmp(s3,"0")==0) break;
>
>
> for(c=0;s3[c]=='0';c++);
> d=0;
> for(c;s3[c]!='\0';c++)
> s1[d++]=s3[c];
> s1[d]='\0';
>
>
> for(c=0;s4[c]=='0';c++);
> d=0;
> for(c;s4[c]!='\0';c++)
> s2[d++]=s4[c];
> s2[d]='\0';
>
>
>
>
> strcpy(s3,s1);
> strcpy(s4,s2);
> strrev(s3);
> strrev(s4);
>
> for(i=0;;i++)
> if(com(fib[i],s3))
> break;
> count=0;
> for(j=i;;j++)
> if(com(s4,fib[j]))
> count++;
> else break;
> printf("%d\n",count);
> }
>
>
> }
>
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator