Advertisement
mfgnik

Untitled

Jan 19th, 2021
1,092
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <cctype>
  2. #include <iostream>
  3. #include <sstream>
  4.  
  5. int main() {
  6.     std::string line;
  7.     int amount_lines = 0, amount_words = 0, amount_letters = 0;
  8.     while (std::getline(std::cin, line)) {
  9.         std::stringstream ss(line);
  10.         std::string word;
  11.         while (ss >> word) {
  12.             ++amount_words;
  13.             for (auto ch : word) {
  14.                 if (std::isalpha(ch)) {
  15.                     ++amount_letters;
  16.                 }
  17.             }
  18.         }
  19.         ++amount_lines;
  20.     }
  21.     std::cout << amount_lines << "\n";
  22.     std::cout << amount_words << "\n";
  23.     std::cout << amount_letters << "\n";
  24.     return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement