inspired by my wife, and i got the code below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
int main ( int argc, char *argv[] )
{
char buf[81];
int i = 0;
memset(buf,0,sizeof(buf));
while(scanf("%s",buf)!=EOF){
for(i=1;i<strlen(buf);i++){
if ( strlen(buf)%i==0 ){
if (strncmp(buf,buf+i,strlen(buf)-i)==0) {
printf ( " k is %d\n",i );
break;
}
}
}
if(i==strlen(buf)){
printf ( "k is %d\n",i );
}
memset(buf,0,sizeof(buf));
}
return EXIT_SUCCESS;

Comments

2016-12-21