Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking all the characters in S​2​​ from S​1​​. Your task is simply to calculate S​1​​−S​2​​ 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 S​1​​ and S​2​​, respectively. The string lengths of both strings are no more than 1. 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 S​1​​−S​2​​ in one line.

Sample Input:

They are students.
aeiou

Sample Output:

Thy r stdnts.

题目分析:利用map将S2种每个字符存入 再遍历S1进行判断
 #define _CRT_SECURE_NO_WARNINGS
#include <climits>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
map<char, int> M;
vector<char> V;
int main()
{
string S1,S2;
getline(cin, S1);
getline(cin, S2);
int length = S2.length();
for (int i = ; i <length; i++)
M[S2[i]] = ;
length = S1.length();
for (int i = ; i < length; i++)
if (!M[S1[i]])
V.push_back(S1[i]);
for (auto it : V)
cout << it;
}

1050 String Subtraction (20分)的更多相关文章

  1. PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  2. PAT Advanced 1050 String Subtraction (20 分)

    Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking ...

  3. PAT练习--1050 String Subtraction (20 分)

    题⽬⼤意:给出两个字符串,在第⼀个字符串中删除第⼆个字符串中出现过的所有字符并输出. 这道题的思路:将哈希表里关于字符串s2的所有字符都置为true,再对s1的每个字符进行判断,若Hash[s1[i] ...

  4. 【PAT甲级】1050 String Subtraction (20 分)

    题意: 输入两个串,长度小于10000,输出第一个串去掉第二个串含有的字符的余串. trick: ascii码为0的是NULL,减去'0','a','A',均会导致可能减成负数. AAAAAccept ...

  5. PAT 解题报告 1050. String Subtraction (20)

    1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...

  6. 1050. String Subtraction (20)

    this problem  is from PAT, which website is http://pat.zju.edu.cn/contests/pat-a-practise/1050. firs ...

  7. PAT (Advanced Level) 1050. String Subtraction (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  8. PAT甲题题解-1050. String Subtraction (20)-水题

    #include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...

  9. A1050 String Subtraction (20 分)

    一.技术总结 这个是使用了一个bool类型的数组来判断该字符是否应该被输出. 然后就是如果在str2中出现那么就判断为false,被消除不被输出. 遍历str1如果字符位true则输出该字符. 还有需 ...

随机推荐

  1. 初探Linux

    这是一个小小新手根据自己对Linux的理解而写下的笔记,记录的是大体的学习内容.记录的笔记不全面,甚至没有整体的概念,但也希望能够给部分人一些入门的帮助,实机基于CentOS 7. 导语:学习一件新事 ...

  2. swoole websocket_server 聊天室--群聊

    centos7  php7.2 swoole4.3 nginx1.8 websocket_server 代码 <?php $server = new Swoole\WebSocket\Serve ...

  3. 深入理解yield from语法

    本文目录 为什么要使用协程 yield from的用法详解 为什么要使用yield from . 为什么要使用协程# 在上一篇中,我们从生成器的基本认识与使用,成功过渡到了协程. 但一定有许多人,只知 ...

  4. js Array方法总结

    修改器方法(9) copyWithin(target: number, start: number, end?: number): this; // 浅复制数组的一部分到同一数组中的另一个位置,并返回 ...

  5. MQTT抓包分析

    1. 概述 MQTT(Message Queuing Telemetry Transport,消息队列遥测传输协议),是一种基于发布/订阅(Publish/Subscribe)模式的轻量级通讯协议,该 ...

  6. 基于SIP协议的性能测试——奇林软件kylinPET

    一.Sip协议简介: SIP(Session Initiation Protocol,会话初始协议)是由IETF(Internet Engineering Task Force,因特网工程任务组)制定 ...

  7. NFS作为根文件系统,挂载超时

    NFS服务器配置正确后,使用ramfs,通过mount能够正常挂载NFS,但是作为ROOTFS无法正常挂载,显示超时. 经查看log,RPC报错-120. 分析结果: 在Ubuntu1804上,nfs ...

  8. shell脚本基础-起始句的含义

    大部分的shell脚本第一行,要么是 #!/bin/bash 要么是 #!/bin/sh 其实第二种是第一种的升级版,增加了协议posix(#!/bin/sh = #!/bin/bash + posi ...

  9. angular自启动过程

    angularJS的源代码整体上来说是一个自执行函数,在angularJS加载完成后,就会自动执行了. 即,在window上暴露一个唯一的全局对象angular, 如果window.angular已经 ...

  10. Selenium系列(二) - 控制浏览器操作的详细解读

    如果你还不想从头学起Selenium,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1680176.html 其次,如果你不懂前端基础知识 ...