九度oj 1049
2015-08-11 11:49
225 查看
题目描述:
输入字符串s和字符c,要求去掉s中所有的c字符,并输出结果。
输入:
测试数据有多组,每组输入字符串s和字符c。
输出:
对于每组输入,输出去除c字符后的结果。
样例输入:
样例输出:
来源:
2009年哈尔滨工业大学计算机研究生机试真题
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char str[1000];char c[10];
while(gets(str))
{
string s=str;
gets(c);
string b=c;
int t=s.find(b,0);
while(t!=string::npos)
{
s=s.erase(t,b.size());
t=s.find(b,0);
}
t=s.find(' ',0);
while(t!=string::npos)
{
s=s.erase(t,1);
t=s.find(' ',0);
}
cout<<s<<endl;
}
}
输入字符串s和字符c,要求去掉s中所有的c字符,并输出结果。
输入:
测试数据有多组,每组输入字符串s和字符c。
输出:
对于每组输入,输出去除c字符后的结果。
样例输入:
heallo a
样例输出:
hello
来源:
2009年哈尔滨工业大学计算机研究生机试真题
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char str[1000];char c[10];
while(gets(str))
{
string s=str;
gets(c);
string b=c;
int t=s.find(b,0);
while(t!=string::npos)
{
s=s.erase(t,b.size());
t=s.find(b,0);
}
t=s.find(' ',0);
while(t!=string::npos)
{
s=s.erase(t,1);
t=s.find(' ',0);
}
cout<<s<<endl;
}
}
相关文章推荐
- 源码安装postgresql
- 哪款PDF转TXT转换器效果好
- 啊大声大声道
- Android reboot
- php实现金字塔图案
- 【Lua】基本函数库
- 让这篇短文帮你快速上手用户体验设计
- foobar2000的使用
- hdu 1312 Red and Black(bfs实现)
- 六款常用的linux C/C++ IDE
- Binary Tree Zigzag Level Order Traversal
- chrome 模拟手机, 默认显示0.4
- 移动端图片上传解决方案localResizeIMG先压缩后ajax无刷新上传
- Webform---修改人员信息
- javafx Cursor
- 第三章 栈和队列
- android测试之monkey
- 【整理】unity3d优化总结篇
- iOS开发笔记--使用blend改变图片颜色
- Java中的Vector向量