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> #include<cstring> using namespace std; int main() { char ch[200]; int i,j,k,n,m,x,y,z,a[180],l,b[180],num[10],num1[10]; while(cin>>ch) { l=strlen(ch); for(i=0;i<=9;i++) { num[i]=0; } for(i=0;i<l;i++) { a[i]=ch[i]-48; num[a[i]]++; } m=0; for(i=2;i<=l;i++) { for(j=0;j<=9;j++)num1[j]=0; for(j=0;j<l;j++) { b[j]=0; } for(j=l-1;j>0;j--) { b[j]+=a[j]*i; b[j-1]+=b[j]/10; b[j]=b[j]%10; } b[0]=b[0]+a[0]*i; x=b[0]/10; if(x!=0) { num1[x]++; } b[0]=b[0]%10; for(j=0;j<l;j++) { num1[b[j]]++; } z=0; for(j=0;j<=9;j++) { if(num[j]!=num1[j]) { z=1; } } if(z==1) { m=1; cout<<ch<<ends<<"is not cyclic"<<endl; break; } } if(m==0) { cout<<ch<<" is 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