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 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 10​4​​. 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.

代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
map<char,int>mp;
int main()
{char s1[maxn],s2[maxn];scanf("%[^\n]%c",&s1);scanf("%[^\n]%c",&s2);int len = strlen(s2);for(int i = 0 ; i < len; i++)mp[s2[i]] = 1;len = strlen(s1);for(int i = 0 ; i < len ; i++){if(mp[s1[i]] == 0)putchar(s1[i]);}putchar('\n');return 0;
}

1050 String Subtraction(20 分)相关推荐

  1. PAT甲级 -- 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 ...

  2. 【PAT甲级 删除字符串中的指定字符】1050 String Subtraction (20 分) C++

    题目 删除字符串中的另一个字符串包含的所有字符. 可以通过判断两个字符串是否为空,来稍微优化一下运行速度 题解C++ #include<iostream> #include<stri ...

  3. 1050 String Subtraction (20 分)_10行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be ...

  4. C++ PAT甲级 1050 String Subtraction (20分)

    Given two strings S​1 and S​2, S=S1−S​2is defined to be the remaining string aftertaking all the cha ...

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

    C/C++中整型数组的下标类型不一定为整型,C C++语言下数组性质与散列有些类似,即散列中的键值对:下标即为关键码,关键码通过散列函数映射得到元素即为值 下标可以为整型,也可以为字符型,简单案例如下 ...

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

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

  7. PAT:1050. String Subtraction (20) AC

    #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; bool ...

  8. PAT甲级1050 String Subtraction

    题目 1050 String Subtraction (20 分) Given two strings S​1 and S​2 , S=S1−S2 is defined to be the remai ...

  9. 1050 String Subtraction

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

  10. PAT甲级1050 String Subtraction:[C++题解]字符串作差

    文章目录 题目分析 朴素算法 hash表优化 题目链接 题目分析 遇到的问题:如何删除下标i的值,我的意思是i后面的需要前移吗?还是有好的解决方法. 笔者想到的是打上标记! string读入一整行的方 ...

最新文章

  1. g-gdb 调试多线程
  2. 五分钟理解yield在python中的简单用法,让你不再迷惑
  3. php实现简单验证码的功能
  4. Python基础(9)水仙花数
  5. 【Flutter】Dart 面向对象 ( 命名构造方法 | 工厂构造方法 | 命名工厂构造方法 )
  6. 超详细 kafka 入门(最佳实践)
  7. 2014公积金新政策对你买房有什么好处?
  8. 2020年十月下旬,再次更新了自己的linkedin工作经历
  9. AcWing 1402. 星空之夜 1月28
  10. codevs1040 统计单词个数
  11. 了解自己计算机硬件设备信息
  12. Zabbix 通过 API 监控 k8s | 技巧
  13. 西门子PLC开关量选择
  14. 【OR】YALMIP 行列式最大化
  15. android手机at指令集,手机AT指令集
  16. markdown实现点击链接下载文件
  17. [编程开发工具-7]:四款功能强大的代码比较工具:Araxis Merge、Beyond compare、DiffMerge、WinMerge
  18. 跑跑卡丁车rush服务器维护,跑跑卡丁车Rush+官网版
  19. UEFI/GPT分区
  20. 聚沙成塔--爬虫系列(二)(python3基础语法)

热门文章

  1. 稳压电源通过什么样的当时分类,怎么去分类
  2. 生鲜电商之毒,食行生鲜模式虽好、恐也难解
  3. linux笔记8.0
  4. Nginx的静态文件合并请求,加快网站的加载速度
  5. Centos6.7安装Apache2.4+Mysql5.6+Apache2.4
  6. HDU1561 The more, The Better(树形dp)
  7. 【Ubuntu^Java】Ubuntu下JDK环境变量的配置
  8. Spring装配集合属性
  9. 各位有没有遇到过这样的问题?
  10. Spring整合jasypt使用说明