PAT 1050. String Subtraction (20)
http://www.patest.cn/contests/pat-a-practise/1050
简单题
1 #include<stdio.h> 2 #include<string.h> 3 4 #define MAXN 11000 5 int hash[256]; 6 7 char s1[MAXN]; 8 char s2[MAXN]; 9 10 int main() { 11 memset(hash, 0, sizeof(hash)); 12 fgets(s1, MAXN, stdin); 13 int len1 = strlen(s1); 14 fgets(s2, MAXN, stdin); 15 int len2 = strlen(s2); 16 for (int i = 0; i < len2 - 1; ++i) { 17 hash[s2[i]] = 1; 18 } 19 for (int i = 0; i < len1 - 1; ++i) { 20 if (!hash[s1[i]]) { 21 putchar(s1[i]); 22 } 23 } 24 putchar('\n'); 25 return 0; 26 }

浙公网安备 33010602011771号