浙大pat1050题解
1050. String Subtraction (20)
Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1 - S2 for any given strings. However, it might not be that simple to do it fast.
Input Specification:
Each input file contains one test case. Each case consists of two lines which gives S1 and S2, respectively. The string lengths of both strings are no more than 104. It is guaranteed that all the characters are visible ASCII codes and white space, and a new line character signals the end of a string.
Output Specification:
For each test case, print S1 - S2 in one line.
Sample Input:
They are students.
aeiou
Sample Output:
Thy r stdnts.
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
#include <algorithm>
using namespace std;
string s1,s2;
bool mycompare(char ch)
{
string::iterator it;
for(it= s2.begin();it!=s2.end();it++)
{
if(ch == *it)
return true;
}
return false;
}
int main()
{
getline(cin,s1);
getline(cin,s2);
sort(s2.begin(),s2.end());
s2.erase(unique(s2.begin(),s2.end()),s2.end());
s1.resize(remove_if(s1.begin(),s1.end(),mycompare)-s1.begin());
cout<< s1<<endl;
return 0;
}
浙大pat1050题解的更多相关文章
- 浙大pat1020题解
1020. Tree Traversals (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Suppo ...
- 浙大pat1013题解
1013. Battle Over Cities (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...
- 浙大pat1009题解
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
- 浙大pat1042题解
1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...
- 浙大pat1019题解
1019. General Palindromic Number (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- 浙大pat 1011题解
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- 浙大PAT 7-06 题解
#include <stdio.h> #include <iostream> #include <algorithm> #include <math.h> ...
- 浙大pat 1012题解
1012. The Best Rank (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...
- 浙大 pat 1003 题解
1003. Emergency (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue As an emerg ...
随机推荐
- UISearchDisplayController UISearchBar
分组表+本地搜索 UISearchDisplayController UISearchBar 的使用 效果图 @interface CityListViewController :UIViewCon ...
- c语言,string库函数itoa实现:将int转换为char*
原型:char *itoa(int value,char *string) 功能:将整数value转换成字符串存入string,默认为十进制; 说明:返回指向转换后的 ...
- XP系统安装ArcGIS10.0需要修改的一个配置
1,右击我的电脑,查看属性. 2,选择“高级”选项卡,“启动和故障恢复”单击“设置”. 3,在“默认操作系统”中单击“编辑”: 4,在弹出的boot.ini文档中把操作系统改成相应的操作系统, ...
- 记录Spring.net学习中遇到的各种问题
1.由于项目中使用了spring.net作为IOC容器,所以看了下相应的博客,熟悉一下这方面的内容,参照博客为博客园刘冬的博客系列: 博客地址:http://www.cnblogs.com/GoodH ...
- 跟我一起玩转Sencha Touch 移动 WebApp 开发1
跟我一起玩转Sencha Touch 移动 WebApp 开发(一) 1.目录 移动框架简介,为什么选择Sencha Touch? 环境搭建 创建项目框架,框架文件简介 创建简单Tabpanel案例 ...
- CYQ.Data 支持WPF相关的数据控件绑定.Net获取iis版本
CYQ.Data 支持WPF相关的数据控件绑定(2013-08-09) 事件的结果 经过多天的思考及忙碌的开发及测试,CYQ.Data 终于在UI上全面支持WPF,至此,CYQ.Data 已经可以方便 ...
- VC中如何设置菜单项的触发状态?
MFC中初始菜单栏如下: 当工程未新建,或者未打开时,后面的观测菜单设置为灰色,不可触发. 当新建工程或者打开工程后,菜单变回可触发状况. 观测菜单如下: 下面以轴力观测菜单为例 轴力初始测量菜单 ...
- Debian下的'aptitude update'失败处理
Hit http://ftp.us.debian.org squeeze/contrib amd64 Packages Hit http://download.proxmox.com squeeze/ ...
- linux常见笔试题
一.填空题: 1. 在Linux系统中,以 文件 方式访问设备 . 2. Linux内核引导时,从文件 /etc/fstab 中读取要加载的文件系统. 3. Linux文件系统中每个文件用 i节点 来 ...
- Android开发之Ubuntu上Eclipse不显示手机设备
一.准备工作 A.开启Android设备,用USB数据线连接到Ubuntu系统. B.启用设备的USB调试模试 C.启动Eclipse,在Devices栏会现一个有很多???号的不明设备 ...