| ||||||||||
| 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 | |||||||||
Re:高手看看为什么wrong?In Reply To:高手看看为什么wrong? Posted by:power721 at 2009-10-04 20:05:40 > #include<stdio.h>
> #include<algorithm>
> main()
> {int n,c,a,b,i,f,j,k,s[4];
> while(scanf("%d",&n)&&n!=-1)
> {c=0;
> printf("N=%d\n",n);
> while(1)
> {f=a=b=i=j=0;
> k=1;
> while(n)
> s[i++]=n%10,n/=10,j++;
> std::sort(s,s+j);
> for(i=0;i<j;i++)
> a+=s[i]*k,b+=s[j-i-1]*k,k*=10;
> n=a-b;
> c++;
> if(!n&&c==1||(c==1&&j!=4))
> {puts("No!!"),f=1;break;}
> printf("%d-%d=%d\n",a,b,n);
> if(n%6174==0)break;
> }
> if(!f)printf("Ok!! %d times\n",c);
> }
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator