Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. int main()
  2. {
  3.     int length, k, j = 0, i = 0, counter = 0;
  4.     char string[256];
  5.    
  6.  
  7.     cout << "vvedite stroky" << endl;
  8.     gets_s(string);
  9.     cout << endl;
  10.     length = strlen(string);
  11.     cout << "dlina stroki=" << length << endl;
  12.  
  13.    
  14.     for (i = 0; i < length; ++i)
  15.     {
  16.         cout << string[i];
  17.     }
  18.  
  19.     for (int i = 0; i < length; ++i)
  20.     {
  21.         if (string[i] != ' ')
  22.         {
  23.             counter++;
  24.         }
  25.  
  26.         else
  27.         { counter = 0; }
  28.  
  29.         if (string[i] % 2 == 0 && (string[i + 1] == ' ' || string[i+1]=='\0'))
  30.         {
  31.             for (int k = i - counter +1; k < length - counter; ++k)
  32.                 string[k ] = string[k + counter];
  33.             length -= counter;
  34.         }
  35.  
  36.     }
  37.         cout << endl;
  38.         for (i = 0; i < length; ++i)
  39.         {
  40.             cout << string[i];
  41.         }
  42.  
  43.         return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement