Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- string input = ""; //cin >> input;
- string output = "";
- string secretCommand = "";
- string text = "";
- string newWord = "";
- int charCounterC = 0;
- int charCounterO = 0;
- int charCounterN = 0;
- while (input != "End")
- {
- cin >> input;
- for (int i = 0; i < input.size(); i++) {
- // Finding the character whose
- // ASCII value fall under this
- // range
- if (input[i] < 'A' || input[i] > 'Z' &&
- input[i] < 'a' || input[i] > 'z')
- {
- // erase function to erase
- // the character
- input.erase(i, 1);
- i--;
- }
- }
- if (input != "End")
- {
- if (input == "c")
- {
- charCounterC++;
- if (charCounterC > 1)
- {
- text += input;
- }
- else
- {
- text = text;
- secretCommand += input;
- }
- }
- else if (input == "o")
- {
- charCounterO++;
- if (charCounterO > 1)
- {
- text += input;
- }
- else
- {
- text = text;
- secretCommand += input;
- }
- }
- else if (input == "n")
- {
- charCounterN++;
- if (charCounterN > 1)
- {
- text += input;
- }
- else
- {
- text = text;
- secretCommand += input;
- }
- }
- else
- {
- text += input;
- }
- if (secretCommand == "con" || secretCommand == "cno" || secretCommand == "ocn" || secretCommand == "onc" || secretCommand == "nco" || secretCommand == "noc")
- {
- text += " ";
- output = text;
- secretCommand = "";
- charCounterC = 0;
- charCounterO = 0;
- charCounterN = 0;
- }
- }
- else
- {
- break;
- }
- }
- if (input == "End")
- {
- cout << output;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement