#include <stdio.h>
int main(){
char *p,s[100];
int i,j,k,n;
while(1)
{
printf("Input string:");
gets(s);
if(strcmp(s, "END") == 0)
return 0;
n=strlen(s);
printf("Output:\n");
k=0;
for(i=2;i<=n/2;i++)
{
if(n%i!=0)
continue;
k++;
printf("%d: ",i);
for(j=0;j<i;j++)
for(p=s+j;p<s+n;p+=i)
printf("%c",*p);
printf("\n");
}
if(k==0)
printf("Impossible\n");
}
return 0;
}
输出超限了 求大神解答I
int main(){
char *p,s[100];
int i,j,k,n;
while(1)
{
printf("Input string:");
gets(s);
if(strcmp(s, "END") == 0)
return 0;
n=strlen(s);
printf("Output:\n");
k=0;
for(i=2;i<=n/2;i++)
{
if(n%i!=0)
continue;
k++;
printf("%d: ",i);
for(j=0;j<i;j++)
for(p=s+j;p<s+n;p+=i)
printf("%c",*p);
printf("\n");
}
if(k==0)
printf("Impossible\n");
}
return 0;
}
输出超限了 求大神解答I