Advertisement
_Kripaka001_

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

Aug 7th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     cout << "you can enter 20 symbols" << endl;
  9.     char a[21];
  10.     cin.getline(a,21);
  11.     cout << "these symbols take part in the test" << endl;
  12.     cout << a << endl;
  13.  
  14.     int letters, gaps, word, b,  num;
  15.     letters = 0;
  16.     gaps = 0 ;
  17.     word = 0;
  18.     b = 0;
  19.     num = strlen (a);
  20.  
  21.  
  22.  
  23.      while ( b < num)
  24.     {
  25.  
  26.                 if (b + 1 == num and a[b] == ' ')
  27.                 {
  28.                     break;
  29.                 }
  30.  
  31.                 if ( a[b] != ' ')
  32.                 {
  33.                     b++;
  34.                     letters++;
  35.                 }
  36.  
  37.                 if ( a[b] == ' ')
  38.                 {
  39.                     b++;
  40.                     gaps++;
  41.                 }
  42.  
  43.     }
  44.  
  45.     b=0;
  46.      while ( b < num)
  47.     {
  48.         if ( a[b] != ' ' )
  49.         {
  50.  
  51.             while ( a[b] != ' ' )
  52.             {
  53.                 b++;
  54.             }
  55.             word++;
  56.         }
  57.         b++;
  58.     }
  59.  
  60.  
  61.  
  62.     cout << "these symbols have   " <<  word <<  "  words" ;
  63.     cout << endl << letters << "    letters" ;
  64.     cout << endl << gaps << "   gaps";
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement