循环单词 c语言

#include<stdio.h>
#include<string.h>
int main()
    {
    int j,len1,k,u,result=0,counter=0,len2,i,n;
    char word[50][50];
    char temp[50];
    scanf("%d",&n);
     for(i=0;i<n;i++)
         scanf("%s",word[i]);
    for(i=0;i<n;i++)
    {
        len1=strlen(word[i]);
         for(j=i+1;j<n;j++)
             {
             len2=strlen(word[j]);
             for(k=0;k<len2;k++)
                { 
                 for(u=0;u<len2;u++)
                 temp[(k+u)%len2]=word[j][u];
                 result=strcmp(temp,word[i]);
                 if(result==0) counter++;
                }
             }
         }
    printf("%d",counter);   
}

 

posted @ 2017-03-17 11:25  爱编程的小羊  阅读(224)  评论(0编辑  收藏  举报