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 |
我已经接近疯了的边缘!!!!!!!!!!!!!!!!!!!请教各位强人,能否帮忙发现错误55555555555555555555555555555~我真的要疯了!!! 感谢趋于正无穷!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #include<iostream.h> #include<string.h> char cNum[18][81]; int n,temp; int nNum[10]={0,0,0,0,0,0,0,0,0,0}; void main() { cin.getline(cNum[0],81); while(strcmp(cNum[0],"-1\0")!=0) { temp=0; for(int i=1;i<=16;i++){ for(int j=0;j<81;j++) cNum[i][j]='\0'; } for(int t=1;t<17;t++){ int nLen=strlen(cNum[t-1]); for(int i=0;i<10;i++) nNum[i]=0; for(i=0;i<nLen;i++){ switch(cNum[t-1][i]-48) { case 0:nNum[0]++;break; case 1:nNum[1]++;break; case 2:nNum[2]++;break; case 3:nNum[3]++;break; case 4:nNum[4]++;break; case 5:nNum[5]++;break; case 6:nNum[6]++;break; case 7:nNum[7]++;break; case 8:nNum[8]++;break; case 9:nNum[9]++;break; } } n=0; for(i=0;i<=9;i++){ if(nNum[i]!=0){ if(nNum[i]<10){ cNum[t][n]=nNum[i]+48; n++; cNum[t][n]=i+48; n++; } if(nNum[i]>=10){ cNum[t][n]=nNum[i]/10+48; n++; cNum[t][n]=nNum[i]%10+48; n++; cNum[t][n]=i+48; n++; } } } // cout<<cNum[t]<<" "<<cNum[t-1]<<" "<<cNum[0]<<endl; if(strcmp(cNum[t],cNum[t-1])==0){ if(t==1){ cout<<cNum[0]<<" is self-inventorying"<<endl; temp=1; goto Loop; } else{ cout<<cNum[0]<<" is self-inventorying after "<<t-1<<" steps"<<endl; temp=1; goto Loop; } } else if(t<16) { for(int j=0;j<t-1;j++){ if(strcmp(cNum[t],cNum[j])==0){ // cout<<cNum[t]<<" "<<cNum[j]<<" "<<cNum[0]<<endl; cout<<cNum[0]<<" enters an inventory loop of length "<<t-j<<endl; temp=1; goto Loop; } } } } Loop: if(temp==0) cout<<cNum[0]<<" can not be classified after 15 iterations"<<endl; cin.getline(cNum[0],81); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator