首页 > 代码库 > 周期串

周期串

#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>#include<algorithm>#include<string>using namespace std;int main(){ 	char w[100]; 	scanf("%s",w); 	int len=strlen(w); 	for(int i=1;i<=len;i++) 	if(len%i==0)  	{int ok=1;for(int j=i;j<len;j++)if(w[j]!=w[j%i]){           ok=0;           break;        }        if(ok)        {           printf("%d\n",i);           break;        }    }    system("pause");    return 0;}

  

周期串