您的位置:首页 > 其它

poj 3981 字符串替换

2016-08-22 21:01 211 查看
字符串替换

TimeLimit:1000MSMemoryLimit:65536K
TotalSubmissions:10871Accepted:5100
Description

编写一个C程序实现将字符串中的所有"you"替换成"we"
Input

输入包含多行数据

每行数据是一个字符串,长度不超过1000
数据以EOF结束
Output

对于输入的每一行,输出替换后的字符串
SampleInput

youarewhatyoudo

SampleOutput

wearewhatwedo


#include<stdio.h>
#include<string.h>
charstr[1003];

intmain(){
inti;
while(gets(str)){
for(i=0;str[i]!='\0';i++){
if(str[i]=='y'&&str[i+1]=='o'&&str[i+2]=='u'){
printf("we");
i+=2;
}else{
printf("%c",str[i]);
}
}
printf("\0");
printf("\n");
}
return0;
}



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: