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 |
高手帮忙看一下!!!!谢谢了!!!!!!#include<iostream> int main() { using namespace std; char c[61],a[61]; int clen; int mtply; int n; int possi; int i,j; while(cin>>c) { possi=1; strcpy(a,c); clen=strlen(c); // if(clen<9) m=clen; // else m=10; for(mtply=2;mtply<=clen;mtply++) { int temp1=0,temp2=0; for(i=clen-1;i>=0;i--) { temp1=((c[i]-'0')*mtply+temp2)/10; c[i]=((c[i]-'0')*mtply+temp2)%10; temp2=temp1; } for(j=clen-1;j>0;j--) { if(c[j]>10) { c[j-1]+=c[j]/10; c[j]=c[j]%10; } } if(c[0]>=10){ possi=0; break;} //第几个数开始相等 for(i=0;i<clen;i++) { if(a[0]==c[i]+'0') n=i; }//比较是否circle for(i=0,j=n;i<clen&&j<clen;i++,j++) { if(a[i]!=c[j]+'0') possi=0; } for(i=0,j=clen-n;i<clen&&j<clen;i++,j++) { if((c[i]+'0')!=a[j]) possi=0; } if(possi==1) break; } if(possi==1) cout<<a<<" is cyclic"<<endl; else cout<<a<<" is not cyclic"<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator