Advertisement
palenda21

Lab7A

Nov 30th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. //найти количество слов, начинающихся на букву w
  2. #include <iostream>
  3. #include <string.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     int c=0;
  8.     char str[100] = {0};
  9.     cout << "Vvedite stroku: ";
  10.     cin.getline(str,100);
  11.     if (str[0] == 'w') {
  12.      c++;
  13.     }
  14.         for (int i = 1; i < strlen(str); i++)
  15.         {
  16.             if ((str[i - 1] == ' ') && (str[i] == 'w'))
  17.             {
  18.                 c++;
  19.             }
  20.         }
  21.      cout << c << endl;
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement