Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <clocale>
- using namespace std;
- void Words (char *s);
- int main(int argc, char *argv[])
- {setlocale (LC_ALL,"Russian");
- char str[255];
- cout<<"Примечание: строка должна заканчиваться одним из символов \n'.' ',' '!' '?' ':' ';' или пробелом \nСтрока не должна быть длинее 256 символов\nВведите строку: ";
- gets (str);
- Words (str);
- return 0;}
- void Words (char *s)
- {int word = 0;
- for (int i = 0;i<255;i++)
- {if ( s[i]=='-' and s[i+1]==' ' )
- {
- word--;
- }
- if (s[i]==' ' or s[i]=='.' or s[i]==',' or s[i]=='!' or s[i]=='?' or s[i]==';' or s[i]==':')
- word++;}
- cout<<"Количество слов: "<<word;
- cout<<endl; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement