1050 String Subtraction(20 分)
1050 String Subtraction(20 分)
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<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 分)相关推荐
- PAT甲级 -- 1050 String Subtraction (20 分)
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking ...
- 【PAT甲级 删除字符串中的指定字符】1050 String Subtraction (20 分) C++
题目 删除字符串中的另一个字符串包含的所有字符. 可以通过判断两个字符串是否为空,来稍微优化一下运行速度 题解C++ #include<iostream> #include<stri ...
- 1050 String Subtraction (20 分)_10行代码AC
立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given two strings S1 and S2, S=S1−S2 is defined to be ...
- C++ PAT甲级 1050 String Subtraction (20分)
Given two strings S1 and S2, S=S1−S2is defined to be the remaining string aftertaking all the cha ...
- 【PAT (Advanced Level) Practice】1050 String Subtraction (20 分)
C/C++中整型数组的下标类型不一定为整型,C C++语言下数组性质与散列有些类似,即散列中的键值对:下标即为关键码,关键码通过散列函数映射得到元素即为值 下标可以为整型,也可以为字符型,简单案例如下 ...
- PAT甲题题解-1050. String Subtraction (20)-水题
#include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...
- PAT:1050. String Subtraction (20) AC
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; bool ...
- PAT甲级1050 String Subtraction
题目 1050 String Subtraction (20 分) Given two strings S1 and S2 , S=S1−S2 is defined to be the remai ...
- 1050 String Subtraction
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be the ...
- PAT甲级1050 String Subtraction:[C++题解]字符串作差
文章目录 题目分析 朴素算法 hash表优化 题目链接 题目分析 遇到的问题:如何删除下标i的值,我的意思是i后面的需要前移吗?还是有好的解决方法. 笔者想到的是打上标记! string读入一整行的方 ...
最新文章
- g-gdb 调试多线程
- 五分钟理解yield在python中的简单用法,让你不再迷惑
- php实现简单验证码的功能
- Python基础(9)水仙花数
- 【Flutter】Dart 面向对象 ( 命名构造方法 | 工厂构造方法 | 命名工厂构造方法 )
- 超详细 kafka 入门(最佳实践)
- 2014公积金新政策对你买房有什么好处?
- 2020年十月下旬,再次更新了自己的linkedin工作经历
- AcWing 1402. 星空之夜 1月28
- codevs1040 统计单词个数
- 了解自己计算机硬件设备信息
- Zabbix 通过 API 监控 k8s | 技巧
- 西门子PLC开关量选择
- 【OR】YALMIP 行列式最大化
- android手机at指令集,手机AT指令集
- markdown实现点击链接下载文件
- [编程开发工具-7]:四款功能强大的代码比较工具:Araxis Merge、Beyond compare、DiffMerge、WinMerge
- 跑跑卡丁车rush服务器维护,跑跑卡丁车Rush+官网版
- UEFI/GPT分区
- 聚沙成塔--爬虫系列(二)(python3基础语法)