Guest User

Stream of letters

a guest
Aug 22nd, 2019
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. main () {
  7.  
  8.     string input;
  9.  
  10.     string currentWord="";
  11.     string output="";
  12.  
  13.     int counter=0;
  14.  
  15.     int counterN=0.0,counterO=0.0,counterC=0.0;
  16.  
  17.     while(input!="End"){
  18.         cin>>input;
  19.        
  20.         if(input=="End"){
  21.             cout<<output<<endl;
  22.             break;
  23.         }
  24.        
  25.         char cinput=input.at(0);
  26.  
  27.         if ((cinput>='a' && cinput<='z') || (cinput>='A' && cinput<='Z')){
  28.  
  29.         if(cinput=='n' && counterN<1){
  30.             counterN++;
  31.             counter++;
  32.  
  33.         } else if (cinput=='o' && counterO<1){
  34.             counterO++;
  35.             counter++;
  36.  
  37.         } else if (cinput=='c' && counterC<1){
  38.             counterC++;
  39.             counter++;
  40.  
  41.         } else {
  42.             currentWord+=input;
  43.         }
  44.         }
  45.  
  46.         if(counter==3){
  47.             output=output+currentWord;
  48.             currentWord=" ";
  49.             output=output+currentWord;
  50.  
  51.             currentWord="";
  52.             counterN=0;
  53.             counterO=0;
  54.             counterC=0;
  55.             counter=0;
  56.  
  57.         }
  58.  
  59.  
  60.     }
  61.  
  62. return 0;
  63. }
Add Comment
Please, Sign In to add comment