
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include<stdio.h>#include<string.h>int main(){ char word[100]; scanf( "%s",word); int len=strlen(word); for(int i=1;i<=len;i++) if(len%i==0) { int ok=1; for(int j=i;j<len;j++) if(word[j]!=word[j%i]) { ok=0; break; } if(ok){printf("%d\n" ,i);break;} } return 0;} |
原文:http://www.cnblogs.com/zhxshseu/p/5285210.html