rint "Censored" if userInput contains the word "darn", else print userInput. End with newline.

#include
#include
using namespace std;

int main() {
string userInput;

userInput = "That darn cat.";

/* Your solution goes here */

return 0;
}

Respuesta :

If you're coding with C++ then the solution would be:

  if (userInput.find("darn") != -1) {

     cout << "Censored" << endl;

  }

  else{

     cout << userInput << endl;

  }

Keep in mind that this will reject any input with the word "darn" in the sentence. This will not filter the word darn if the capitalization is in different formats like "Darn, dArn, daRn, darN, DARN".