C ++ engineers to develop a daily problem

topic:

Topics from bovine customer network: https://www.nowcoder.com/practice/f0db4c36573d459cae44ac90b90c6212?tpId

Two input string, the second string to delete all the characters from the first character string. For example, enter "They are students." And "aeiou", the first string after deletion becomes "Thy r stdnts."

 

 

answer:

 1 #include<iostream>
 2 #include<string>
 3 using namespace std;
 4 
 5 int main(){
 6     string s1, s2;
 7     getline(cin, s1);
 8     getline(cin, s2);
 9     int a[256] = { 0 };
10     for (int i = 0; i < s2.size(); i++){
11         a[s2[i]]++;
12     }
13     string res;
14     for (int i = 0; i < s1.size(); i++){
15         if (a[s1[i]] == 0){
16             res += s1[i];
17         }
18     }
19     cout << res << endl;
20     return 0;
21 }

Answer key to this problem is the use of the String class interface.

Guess you like

Origin www.cnblogs.com/Kaniso-Vok/p/11824014.html