fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool isNeededChar(char c) { switch(c) { case '.': case '!': case '?': return true; default: return false; } }
  5.  
  6. int main() { int counter = 0; string text; getline(cin, text); for(int i = 1; i < text.length(); i++) { if(isNeededChar(text.at(i))) { if(!isNeededChar(text.at(i - 1))) { counter++; } } } cout << counter << endl; return 0; }
Success #stdin #stdout 0.01s 5516KB
stdin
BOQBJ !?
stdout
1