Advertisement
mercMatvey4

Untitled

Feb 16th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. setlocale(LC_ALL,"");
  8. char str[256];
  9. cout << "Введите строку : ";
  10. cin.getline(str,256);
  11. double average, summa = 0 , count = 0;
  12. char* ptr=strtok(str," .,!?");
  13. do {
  14. summa = summa + strlen(ptr);
  15. count += 1;
  16. }
  17. while(ptr=strtok(NULL," .,!?"));
  18. average = summa / count ;
  19. cout << "Средняя длинна слов равна : " << average << endl;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement