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 |
为什么Output Limit Exceed??简直不能忍!!高手给看一下输出行吗?谢了#include <iostream.h> #include <stdlib.h> #include <string.h> int cmp1(const void *a,const void *b) { return *(char*)a-*(char*)b; } int cmp2(const void *a,const void *b) { return -*(char*)a+*(char*)b; } void main() { int count; int num; char num1[5],num2[5]; int max,min; while(1) { count=0; cin>>num; if(num==-1) break; cout<<"N="<<num<<":"<<endl; if(num%1111==0 || num>9999 || num<1000) { cout<<"No!!"<<endl; continue; } itoa(num,num1,10); itoa(num,num2,10); while(1) { count++; qsort(num1,strlen(num1),sizeof(char),cmp1); qsort(num2,strlen(num2),sizeof(char),cmp2); min=atoi(num1); max=atoi(num2); cout<<max<<"-"<<min<<"="<<max-min<<endl; if(max-min==0 || max-min==6174) { cout<<"Ok!! "<<count<<" times"<<endl; break; } itoa(max-min,num1,10); itoa(max-min,num2,10); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator