编程:从s所指字符串中删除给定的字符,同一字母大小写按不同字符处理

2024-12-18 10:44:49
推荐回答(2个)
回答1:

采用字符串匹配算法。网上有答案

回答2:

#include

using namespace std;

int main()
{
char s1[100],s2[100],c;
cin >> s1;
cin.get();
cin >> c;
for (int i = 0;i < 100;i ++)
s2[i] = '\0';
for (int i = 0,j = 0;s1[i] != '\0';i ++)
if (s1[i] != c)
s2[j ++] = s1[i];
cout << s2 << endl;
return 0;
}