Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7. setlocale(LC_ALL,"Russian");
  8. int words;
  9. string s1;
  10. cout<<"Введите предложение:"<<endl;
  11. getline(cin, s1);
  12. char c[s1.size()+1];
  13. for(int i=0;i<s1.size();i++)
  14. {
  15. c[i]=s1[i];
  16. }
  17. for(int i=0;i<=s1.size();i++)
  18. {
  19. if(c[i]==' '||c[i]=='\0')
  20. {
  21. words++;
  22. }
  23. }
  24. cout<<"Количество слов:";
  25. cout<<words;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement