您的位置:首页 > 其它

[原]NYOJ-字符串替换-113

2013-07-10 13:43 225 查看
大学生程序代写

/*http://acm.nyist.net/JudgeOnline/problem.php?pid=113

字符串替换

时间限制:3000 ms | 内存限制:65535 KB

难度:2

描述

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

输入

输入包含多行数据

每行数据是一个字符串,长度不超过1000

数据以EOF结束

输出

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

样例输入

you are what you do

样例输出

we are what we do

*/

#include<stdio.h>

#include<string.h>

int main(){

char a[1010];

int b[1010];

int i;

while(gets(a)){

int len=strlen(a);

int j=0,k=0;

for(i=0;i<len;i++)

{

if(a[i]=='y'&&a[i+1]=='o'&&a[i+2]=='u')

{

printf("we");

i=i+2;//跳过

}

else printf("%c",a[i]);

}

printf("\n");

}

return 0;

}

作者:chao1983210400 发表于2013-7-10 13:43:25 原文链接

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