1、http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2092
2、错在只要字符串中出现EOF就结束,另外需要注意i+3,i-1的边界
3、
unpinked is an 8 letter word. Honest! vv is ok, d123d is ok, 123dd is not i received mail from liechtenstein .. ...adding means to imitat.#$!%%$e EOF
4、代码:
#include<stdio.h>
#include<string.h>
char str[100];
char a[100];
int visit[100];
int main()
{
int j;
while(gets(str))
{
memset(visit,0,sizeof(visit));
memset(a,0,sizeof(a));
//printf("%s",str);
//if(strcmp(str,"EOF")==0)
//break;
int flag=0;
int l=strlen(str);
for(int i=0;i<strlen(str);i++)
{
if(i+3<l&&str[i]=='p'&&str[i+1]=='i'&&str[i+2]=='n'&&str[i+3]=='k'&&visit[i]==0&&visit[i+1]==0&&visit[i+2]==0&&visit[i+3]==0)
{
printf("floyd");
visit[i]=1;
visit[i+1]=1;
visit[i+2]=1;
visit[i+3]=1;
}
else if(i+1<l&&str[i]=='e'&&str[i+1]=='i'&&visit[i]==0&&visit[i+1]==0)
{
if((str[i-1]!='c'&&i-1>=0)||(i==0))
{printf("ie");
}
else
{
printf("ei");
}
visit[i]=1;
visit[i+1]=1;
}
else if(i+1<l&&str[i]=='d'&&str[i+1]=='d'&&visit[i]==0&&visit[i+1]==0)
{
printf("p");
visit[i]=1;
visit[i+1]=1;
}
else if((str[i]==' '&&visit[i]==0)||(str[i]>='a'&&str[i]<='z'&&visit[i]==0))
{
printf("%c",str[i]);
visit[i]=1;
}
else if(str[i]=='E'&&str[i+1]=='O'&&str[i+2]=='F'&&i+2<l)
{
flag=1;
break;
}
}
if(flag==1)
break;
printf("\n");
}
return 0;
}
/*
unpinked is an 8 letter word. Honest!
vv is ok, d123d is ok, 123dd is not
i received mail from liechtenstein
.. ...adding means to imitat.#$!%%$e
EOF
*/