PAT甲级练习1050. String Subtraction (20)
来源:互联网 发布:修改软件端口号 编辑:程序博客网 时间:2024/05/15 07:30
1050. String Subtraction (20)
时间限制
100 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
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.aeiouSample Output:
Thy r stdnts.
建立一个字符到布尔值的映射关系表征要删掉的字符即可
#include <iostream>#include <cstdio>#include <algorithm>#include <vector>#include <map>#include <set>#include <string>#include <string.h>using namespace std;const int MAX=1e4+10;char c1[MAX], c2[MAX], ans[MAX];int flag[256];int main(){int n, j, cnt=0;gets(c1); gets(c2);for(int i=0; i<strlen(c2); i++){flag[c2[i]]=true;}for(j=0; j<strlen(c1); j++){if(!flag[c1[j]]) ans[cnt++] = c1[j]; }printf("%s\n", ans);cin>>n;return 0;}
0 0
- PAT甲级练习1050. String Subtraction (20)
- 【PAT甲级】1050. String Subtraction (20)
- 1050. String Subtraction (20) PAT甲级
- PAT(甲级)1050. String Subtraction (20)
- PAT甲级1050. String Subtraction (20)
- 1050. String Subtraction (20)-PAT甲级
- PAT 甲级 1050. String Subtraction (20)
- PAT甲级 1050. String Subtraction (20)
- 1050. String Subtraction (20)-PAT甲级真题(哈希)
- 1050. String Subtraction (20)-PAT
- PAT 1050. String Subtraction (20)
- PAT 1050. String Subtraction (20)
- pat 1050. String Subtraction (20)
- PAT 1050. String Subtraction (20)
- PAT 1050. String Subtraction (20)
- PAT 1050. String Subtraction
- PAT 1050. String Subtraction
- 【PAT】1050. String Subtraction
- 10006---HTML&CSS--简介
- Python
- 【Unity Shader】如何修改LineRenderer与TrailRenderer 中的颜色
- 4540: [Hnoi2016]序列
- ccs知识点总结
- PAT甲级练习1050. String Subtraction (20)
- 网站前后端交互学习有感
- unity 黑白shader
- BZOJ 2716 [Violet 3]天使玩偶 KDtree
- 414. Third Maximum Number Easy
- ACM 海贼王之伟大航路(深搜剪枝)
- 落谷 P1140 相似基因
- jQuery客户端编程实例上
- Codeforces 777B-Game of Credit Cards