1050. String Subtraction (20)-PAT甲级
2017-04-17 14:10
351 查看
题目:
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<cstdio> #include<cstring> char a[10005],b[10005]; int HashTable[128]={0}; int main(){ gets(a); gets(b); int lenA=strlen(a); int lenB=strlen(b); for(int i=0;i<lenB;i++){ HashTable[b[i]]=1; } for(int i=0;i<lenA;i++){ if(HashTable[a[i]]==0){ printf("%c",a[i]); } } return 0; }
相关文章推荐
- 1058. A+B in Hogwarts (20)-PAT甲级
- 1061. Dating (20)PAT甲级
- 1050. String Subtraction (20) PAT甲级
- 1024. 科学计数法 (20)PAT乙级&&1073. Scientific Notation (20)PAT甲级
- 1081. Rational Sum (20)-PAT甲级
- 1019. 数字黑洞 (20)PAT乙级 &1069. The Black Hole of Numbers (20) PAT甲级
- 1059. C语言竞赛(20) PAT 乙级&&1116. Come on! Let's C (20) PAT甲级
- 1039. 到底买不买(20) PAT 乙级&&1092. To Buy or Not to Buy (20)PAT甲级
- 1112. Stucked Keyboard (20) PAT甲级
- 1054. 求平均值 (20) PAT乙级&&1108. Finding Average (20)PAT甲级
- 1015. Reversible Primes (20)PAT甲级
- 1042. Shuffling Machine (20)-PAT甲级
- 1046. Shortest Distance (20)-PAT甲级
- 1077. Kuchiguse (20) PAT甲级
- 1029. 旧键盘(20) PAT乙级&1084. Broken Keyboard (20)PAT甲级
- 1023. Have Fun with Numbers (20) PAT甲级
- U-boot-1.1.6-2008R1到vdsp5(bf561)的移植记录(20):INPUT_SECTION_ALIGN
- 07-3. 数素数 (20)
- 1069. The Black Hole of Numbers (20)
- PAT (Advanced Level) Practise 1128 N Queens Puzzle (20)