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. 64位下Hook NtOpenProcess的实现进程保护 + 源码 (升级篇 )

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

  2. tomcat的OutOfMemoryError内存溢出解决方法

    在tomcat安装路径bin目录下 打开catalina.bat在第一行加上 set JAVA_OPTS=-Xms64m -Xmx256m -XX:PermSize=128M -XX:MaxNewSi ...

  3. UI基础UIWindow、UIView

    UI基础UIWindow.UIView 在PC中,应用程序多是使用视窗的形式显示内容,手机应用也不例外,手机应用中要在屏幕上显示内容首先要创建一个窗口承载内容,iOS应用中使用UIWindow.UIV ...

  4. Java笔记:枚举类

    1.一个类的实例是有限且固定的,这个类称为枚举类.比如季节类,只有四个对象(春.夏.秋.冬) 2.手动实现一个枚举类(1)通过private将构造器隐藏起来(2)把这个类的所有可能实例都使用priva ...

  5. 转载:JavaScript多线程编程简介

    虽然有越来越多的网站在应用AJAX技术进行开发,但是构建一个复杂的AJAX应用仍然是一个难题.造成这些困难的主要原因是什么呢?是与服务器的异步通信问题?还是GUI程序设计问题呢?通常这两项工作都是由桌 ...

  6. error:“Unexpected namespace prefix "xmlns" found for tag LinearLayout”

    错误“Unexpected namespace prefix "xmlns" found for tag LinearLayout”的解决方法 androidUnexpected ...

  7. poj1483 It's not a Bug, It's a Feature!

    It's not a Bug, It's a Feature! Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 1231   ...

  8. Oracle笔记(六) 多表查询

    最近看了李兴华的oracle视频,这是网上别人做的笔记非常细致,分享给大家,第六篇 原创地址:http://www.cnblogs.com/mchina/archive/2012/09/07/2651 ...

  9. Hadoop完全分布式搭建过程中遇到的问题小结

    前一段时间,终于抽出了点时间,在自己本地机器上尝试搭建完全分布式Hadoop集群环境,也是借助网络上虾皮的Hadoop开发指南系列书籍一步步搭建起来的,在这里仅代表hadoop初学者向虾皮表示衷心的感 ...

  10. JS网站当前日期在IE9、Chrome和FireFox中年份显示为113年的解决方法 getFullYear();

    JS网站当前日期在IE9.Chrome和FireFox中年份显示为113年的解决方法 getFullYear();