Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int sym_num = 0;
- // определение количества слов в строке
- int wcount(string stroka)
- {
- bool f;
- int i, word;
- word = 0;
- f = false;
- for(i = 0; stroka[i] != '\0'; i++)
- {
- if (stroka[i] != ' ' && f == false)
- {
- word++;
- f = true;
- }
- else if (stroka[i] == ' ') f = false;
- sym_num++;
- }
- sym_num/=2;
- return word;
- }
- // определение количества гласных в строке
- int count_vowels (string stroka) {
- int count=0;
- string vowels= {"аоиеёэыуюяАОИЕЁЭЫУЮЯ"}; // 20 букв
- for (int i=0;i<sym_num;i++) {
- for (int j=0;j<19;j++) {
- if (int(stroka[i])==int(vowels[j])) {count++;}
- }
- }
- return count;
- }
- // определение количества согласных в строке
- int count_consonants (string stroka) {
- int count1=0;
- string vowels= {"бвгджзйклмнпрстфхцчшщБВГДЖЗЙКЛМНПРСТФХЦЧШЩ"}; // 42 буквы
- int dlina_stroka=0;
- for (int i=0;i<sym_num;i++) {
- for (int j=0;j<41;j++) {
- if (int(stroka[i])==int(vowels[j])) {count1++;}
- }
- }
- return count1;
- }
- int main()
- {
- setlocale(LC_CTYPE, "Russian");
- string stroka;
- getline(cin,stroka);
- cout << wcount(stroka);
- cout << endl;
- cout << count_vowels(stroka);
- cout << endl;
- cout << count_consonants(stroka);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement