POJ 3981 字符串替换
来源:互联网 发布:数据库应用教程 编辑:程序博客网 时间:2024/06/06 12:26
B - 字符串替换
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uDescription
编写一个C程序实现将字符串中的所有"you"替换成"we"
Input
输入包含多行数据
每行数据是一个字符串,长度不超过1000
数据以EOF结束
每行数据是一个字符串,长度不超过1000
数据以EOF结束
Output
对于输入的每一行,输出替换后的字符串
Sample Input
you are what you do
Sample Output
we are what we do
#include <stdio.h>#include <string.h>int main(){ char str[1010],str1[1001]; while(gets(str)!=NULL) { int len=strlen(str); int j=0,i; for(i=0;i<len-2;) { if(str[i]=='y' && str[i+1]=='o' && str[i+2]=='u') { str1[j++]='w'; str1[j++]='e'; i=i+3; } else { str1[j++]=str[i]; i++; } } if(str[len-2]!= 'o' || str[len-1]!='u') { str1[j++]=str[len-2]; str1[j++]=str[len-1]; } str1[j]='\0'; printf("%s\n",str1); } return 0;}
0 0
- POJ 3981 字符串替换
- POJ-3981-字符串替换
- POJ 3981 字符串替换
- POJ--3981:字符串替换
- poj 3981 字符串替换
- POJ 3981 字符串替换 G++
- POJ 3981 字符串替换(水~)
- POJ 1572 字符串替换
- POJ 1917 字符串替换
- POJ 3981 字符串替换 (string的基础使用)
- hdu-3981-字符串替换
- pku--3981 给定字符串替换
- POJ,北大OJ3981,字符串替换题目。。简单的输出。
- poj 1148 TEX Quotes 【水题(字符串替换)】【周赛】
- 字符串替换
- 字符串替换
- 替换字符串
- 字符串替换
- hdu 4862 KM算法 最小K路径覆盖的模型
- POJ 1141 Brackets Sequence (区间DP)
- Hibernate核心接口
- 【POMELO】深入浅出node.js游戏服务器开发
- 字符编码笔记:ASCII,Unicode和UTF-8
- POJ 3981 字符串替换
- 设计模式之桥接模式 待续
- POJ 1731 Orders
- ACE 多线TCP服务端-客户端通信
- C语言中最常用标准库函数
- 线段树Codeforces Beta Round #99 (Div. 1)C
- GWT 批量上传
- HDU 1069 Monkey and Banana 动态规划
- windows下expect使用小结