#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int n,t,v,i,j,k,sum;
char str[90];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",str);
for(t=1;t<=strlen(str);t++)
{
if(strlen(str)%t==0)
{
for(j=0;j<strlen(str);j+=t)
{
if(0!=strncmp(str,str+j,t))
break;
}
if(j>=strlen(str))
{
printf("%d\n\n",t);
break;
}
}
}
}
return 0;
}
strncmp函数比较前n个字符
函数原型 :extern int strncmp(char*str1,char *str2,int n)
参数说明:str1为第一个要比较的字符串,str2为第二个要比较的字符串,n为指定的str1与str2的比较字符数。
库名:#include