1050. String Subtraction (20)

时间限制
10 ms
内存限制
32000 kB
代码长度限制
16000 B
判题程序
Standard

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题解的更多相关文章

  1. 浙大pat1020题解

    1020. Tree Traversals (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Suppo ...

  2. 浙大pat1013题解

    1013. Battle Over Cities (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...

  3. 浙大pat1009题解

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  4. 浙大pat1042题解

    1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...

  5. 浙大pat1019题解

    1019. General Palindromic Number (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...

  6. 浙大pat 1011题解

    With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...

  7. 浙大PAT 7-06 题解

    #include <stdio.h> #include <iostream> #include <algorithm> #include <math.h> ...

  8. 浙大pat 1012题解

    1012. The Best Rank (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...

  9. 浙大 pat 1003 题解

    1003. Emergency (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue As an emerg ...

随机推荐

  1. springmvc国际化 基于请求的国际化配置

    springmvc国际化 基于请求的国际化配置 基于请求的国际化配置是指,在当前请求内,国际化配置生效,否则自动以浏览器为主. 项目结构图: 说明:properties文件中为国际化资源文件.格式相关 ...

  2. thinkphp实现自动登录

    网页上经常有一些自动登录的checkbox,勾选后,下次进入该网站,无需登录,即可执行一些需要登录才能执行的操作.上班无事,用thinkphp做了下 1 下面是一个很普通的form表单,有一个chec ...

  3. 64位下Hook NtOpenProcess的实现进程保护 + 源码 (升级篇 )

    64位下Hook NtOpenProcess的实现进程保护 + 源码 (升级篇 ) [PS: 如果在64位系统下,出现调用测试demo,返回false的情况下,请修改Hook Dll的代码] glhH ...

  4. T4模板与数据访问层的分离

    当在企业级应用中使用EF时,会发现实体类库与数据访问层是分离的. 来一张效果图. 具体步骤: 1.运用EF生成原始的实体类 在程序集中添加完ADO.NET实体数据模型后,生成相应的实体类,此时,T4模 ...

  5. 二.redis 数据类型

    本文介绍下redis支持的各种数据类型包括string,list ,set ,sorted set 和hash 1. keysredis本质上一个key-value db,所以我们首先来看看他的key ...

  6. 对Git的一些理解

    使用Git都快2年了,能够说熟练使用git,遇到不会的也可以自己查询git帮助手册.平时可以根据shell的管道命令,组合一些命令比如git show commitID | grep “diff”来看 ...

  7. jQuery的MP3、视频播放器jPlayer

    jplayer是一个纯代码的html5音乐.视频播放器. 支持单个.多个音乐或视频播放,支持各种主流的媒体文件. 使用方法: 1.提供json参数 [ { "title": &qu ...

  8. MacOSX中使用NSWindow创建背景透明的窗体

    1.Windows 在window上创建异形窗体必须要使用WS_EX_LAYERED样式,再调用SetLayeredWindowAttributes设置透明度或者透明颜色属性.用updatelayer ...

  9. linux 原生系统发送电子邮件 (在本地与因特网)

    有用的资料在 Linux mail 命令 http://www.cnblogs.com/JemBai/archive/2012/01/24/2329136.html 还有这里 Linux系统下mail ...

  10. 传统的MVC模式

    对于MVC模式,我们可以将可视化UI呈现,UI处理逻辑和业务逻辑分别定义在View,Controller,和Model中. 可视化UI呈现->View UI处理逻辑->Controller ...