Advertisement
_Kripaka001_

ищем слова 1(3)

Jun 28th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     cout << "you can enter 20 symbols" << endl;
  8.     char a[21];
  9.     cin.getline(a,21);
  10.     cout << "these symbols take part in the test" << endl;
  11.     cout << a << endl;
  12.  
  13.     int b=0;
  14.     int word=0;
  15.     int letters=0;
  16.     int gaps=0;
  17.  
  18.     while ( b < 21)
  19.     {
  20.         if ( a[b] != ' ')
  21.             {
  22.                 while (a[b] != ' ')  
  23.                 {
  24.                     letters++;
  25.                     b++;
  26.                 }
  27.                 word++;
  28.             }
  29.             else
  30.             {
  31.                 while (a[b] = ' ' )
  32.                 {
  33.                     gaps++;
  34.                 }
  35.             }
  36.     }
  37.  
  38.  
  39.     cout << "these symbols have   " <<  word  ;
  40.     cout << "  words";
  41.     cout << endl << letters;
  42.     cout << "letters" << endl;
  43.     cout << gaps << "  gaps";
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement