#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
string previous;
string current;
vector<string> dislikes(4);
dislikes [0] = "cat1";
dislikes [1] = "cat2";
dislikes [2] = "cat3";
dislikes [3] = "cat4";
while(cin >> current){
for(int i = 0; i<dislikes.size(); ++i){
if(current==dislikes[i]){
cout << "BLEEP ";}
else if(i=4);
{cout << current << " ";}
};
previous = current;
};
return 0;
};
它只会在 cat1 出现在句子中时将其替换为 bleep,而不会出现在其他句子中。我不知道为什么,多年来一直盯着它看。