1050 String Subtraction

原创 2015年11月21日 10:10:13

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>
using namespace std;
int main(){
	for(string s1;getline(cin,s1);){
		string s2;
		getline(cin,s2);
		int flag[257]={0};
		for(int i = 0;i < s2.length();i++){
			flag[s2[i]] = 1;
		}
		for(int i = 0; i < s1.length();i++){
			if(!flag[s1[i]]){
				cout<<s1[i];
			}
		}
		cout<<endl;
	}
	return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

【PAT (Advanced Level)】1050. String Subtraction (20)

1050. String Subtraction (20) 时间限制 10 ms 内存限制 32000 kB 代码长度限制 1600...

pat 1050. String Subtraction (20)

1050. String Subtraction (20) 时间限制 10 ms 内存限制 65536 kB 代码长度限制 1600...

问题 D: String Subtraction (20)

题目描述 Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking al...

Output result string after numbers addition and subtraction

通过键盘输入100以内正整数的加、减运算式,请编写一个程序输出运算结果字符串。 输入字符串的格式为:“操作数1 运算符 操作数2”,“操作数”与“运算符”之间以一个空格隔开

CSU1610: Binary Subtraction

Description Zuosige always has bad luck. Recently, he is in hospital because of pneumonia. While ...

Dark Frame Subtraction

在手册阅读中,经常能看到,直译为暗帧么?那作用又是什么,一直不解。 问度娘得到了wiki的介绍: In digital photography, dark-frame subtraction is...

Background Subtraction and Modeling 常见的目标检测中的背景建模方法漫谈

转载者的话: 最近一直在看background subtraction and modeling。正如如下链接的第一个回帖所说,背景建模虽然最近研究不是很热,但对视频的处理至关重要,甚至直接...

Subtraction Game 1+gcd

Subtraction Game 1 Problem code: AMSGAME1 All Submissions All submissions f...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)