"Idea": Use string replace method on the line, pay attention to the topic " inside no space", is not inside. So you need to consider the case where the string is empty or there are spaces around it. You can't use CIN anymore, you need to use gets and so on. So you need to convert char[] into a string step. In addition, Char cannot define a character on the same line and then define a string. Conversely, you might not get a character pointer to a character error.
"AC Code":
#include <iostream> #include <algorithm> #include <string> #include <cstdio> #include < Cstring>using namespace Std;int Main () {//freopen ("In.txt", "R", stdin); int i = 0;char ss[100], c;gets (ss); Cin >> c;string str = ss;for (i = 0; i < str.length (); i++) {if (str[i] = = c) {str.replace (I, 1, ""); i--;}} cout << str;}
Blue Bridge Cup ALGO-89 character Delete (string)