输入两个字符串,从第一字符串中删除第二个字符串中所有的字符。例如,输入 ”They are students.” 和 ”aeiou” ,则删除之后的第一个字符串变成 ”Thy r stdnts.”
#include <iostream>
#include <cstring>
using namespace std;
void exchange(char a[], char b[])
{
int len1 = strlen(a);
int len2 = strlen(b);
int i = 0;
for (i = 0; i < len1; i++)
{
int j = 0;
for (j = 0; j < len2; j++)
{
if (a[i] == b[j])
a[i] = '1';
}
}
for (i = 0; i < len1; i++)
{
if (a[i] != '1')
cout<<a[i];
}
}
int main()
{
char a[]= "They are students.";
char b[] = "aeiou";
exchange(a, b);
return 0;
}