Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4. #include <sstream>
  5.  
  6. using namespace std;
  7.  
  8. int main (){
  9.  
  10. register unsigned int count_word (0); // Слова
  11. register unsigned int count_letter (0); // Буквы
  12. string strone = "Moscow is the capital of Great Britain"; // Строка один
  13. string strtwo; // Пустая строка.
  14. istringstream str (strone);
  15.  
  16. while (str >> strtwo){ // Подчитываем количесво строк.
  17. count_word ++;
  18. }
  19.  
  20. for (int i(0); strone[i]; i++){
  21. if(strone[i] != ' '){
  22. count_letter ++;
  23. }
  24. }
  25.  
  26. cout << "Numbe of letters: " << count_word << endl << "Number of words: "
  27. << count_letter << endl << "Average number of words: " << count_letter/count_word << endl;
  28.  
  29. system ("pause");
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement