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 <stdio.h> #include <string.h> char str[100]; char k[100]; void mult(char s[],int n) { int d=0,sum,i,l; l=strlen(s); for(i=0;i<l;i++) { sum=(s[i]-'0')*n+d; d=sum/10; s[i]=sum%10+'0'; } while(d) { s[i]=d%10+'0'; d/=10; } } int main() { int i,j,count; while(scanf("%s",str)!=EOF) { strrev(str); strcpy(k,str); int length; length=strlen(str); mult(str,length+1); strrev(k); count=0; for(i=0;i<length;i++) if(str[i]=='9') count++; if(count==length) printf("%s is cyclic",k); else printf("%s is not cyclic",k); printf("\n"); } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator