Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Пусть программа запрашивает строку символов у пользователя, а потом извещает сколько в нем слов.
- #include "stdafx.h"
- #include "iostream"
- #include "string"
- using namespace std;
- int main()
- {
- size_t i = 0;
- string s;
- bool isfirst = true;
- do
- {
- getline(cin, s);
- size_t it = 0;
- if (isfirst)
- while (it<s.size()) {
- it = s.find(' ', it); ++i;
- if (it<s.size()) it++;
- isfirst = false;
- };
- } while (s[s.size() - 1] != '.');
- cout << endl;
- cout << i << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement