Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL,"Russian");
- int words;
- string s1;
- cout<<"Введите предложение:"<<endl;
- getline(cin, s1);
- char c[s1.size()+1];
- for(int i=0;i<s1.size();i++)
- {
- c[i]=s1[i];
- }
- for(int i=0;i<=s1.size();i++)
- {
- if(c[i]==' '||c[i]=='\0')
- {
- words++;
- }
- }
- cout<<"Количество слов:";
- cout<<words;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement