String Subtraction
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.
//主要是时限,所以该想办法用Hash。
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
string ss1,ss2;
int i;
while(getline(cin,ss1))
{
getline(cin,ss2);
map<char,bool> mm;
for(i=0;i<ss1.length();i++)
mm[ss1[i]]=true;
for(i=0;i<ss2.length();i++)
mm[ss2[i]]=false;
for(i=0;i<ss1.length();i++)
if(mm[ss1[i]])
cout<<ss1[i];
cout<<endl;
}
return 0;
}
String Subtraction的更多相关文章
- PAT 解题报告 1050. String Subtraction (20)
1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...
- PAT 1050 String Subtraction
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
- 1050 String Subtraction (20 分)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be the ...
- pat1050. String Subtraction (20)
1050. String Subtraction (20) 时间限制 10 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Giv ...
- pat 1050 String Subtraction(20 分)
1050 String Subtraction(20 分) Given two strings S1 and S2, S=S1−S2 is defined to be the ...
- PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
- PAT_A1050#String Subtraction
Source: PAT A1050 String Subtraction (20 分) Description: Given two strings S1 and S2, S=S1− ...
- PAT甲级——1050 String Subtraction
1050 String Subtraction Given two strings S1 and S2, S=S1−S2 is defined to be the remain ...
- 1050. String Subtraction (20)
this problem is from PAT, which website is http://pat.zju.edu.cn/contests/pat-a-practise/1050. firs ...
随机推荐
- Customer reviews on Lexia3 V48 diagnostic tool in EOBD2.FR
Robert said: Ok, so I bought a Lexia3 interface from EOBD2.FR in 2010. I have had no issues over the ...
- Flask的部署
当前对部署flask的一些学习: 1.全局安装nginx 1.1 nginx的配置文件怎么写? $ sudo rm /etc/nginx/sites-enabled/default $ sudo to ...
- mongoDB 插入数据 用java实现
import java.net.UnknownHostException; import com.mongodb.BasicDBObject; import com.mongodb.DB; impor ...
- javaweb学习总结五(内省、beanUtils工具包)
一:内省的概念 1:内省是反射的一种特例,由于在反射中频繁的操作javabean,所以为了方便反射 javabean,sun公司开发出一套API提高效率. 2:javaBean,就是用来封装客户端请求 ...
- Cisco 交换机的操作
Cisco的工作模式 Cisco设备有常用模式为:用户模式.特权模式.全局模式.端口模式.首先它们之间呈现出递进关系:用户模式->特权模式->全局模式->端口模式 1.用户模式 交换 ...
- 【置换,推理】UVa 1315 - Creaz tea party
Dsecription n participants of «crazy tea party» sit around the table. Each minute one pair of neighb ...
- 关于Class.forName("oracle.jdbc.driver.OracleDriver");报ClassNotFoundException 的异常
关于try { Class.forName("oracle.jdbc.driver.OracleDriver"); }catch(ClassNotFoundException e) ...
- Nginx - Events Module
The Events module comes with directives that allow you to configure network mechanisms. Some of the ...
- 在VS2010中使用附加进程的方式调试IIS中的页面
h3{background:#333333; } 准备篇-配置IIS环境 在发布网站之前,需要安装iis环境! 之后点击确定即可! 发布网站至IIS-附加到进程调试 1. 用VS2010将 ...
- HDU(搜索专题) 1000 N皇后问题(深度优先搜索DFS)解题报告
前几天一直在忙一些事情,所以一直没来得及开始这个搜索专题的训练,今天做了下这个专题的第一题,皇后问题在我没有开始接受Axie的算法低强度训练前,就早有耳闻了,但一直不知道是什么类型的题目,今天一看,原 ...