STANAANDREY

Untitled

Apr 12th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. char s[100];
  7.  
  8. int main()
  9. {
  10.  
  11.     cin.getline(s,100);
  12.     int k=0,ok=0;
  13.  
  14.     for(unsigned i=0;i<strlen(s);i++)
  15.     {
  16.         k++;
  17.         if(i==strlen(s)-1 or s[i+1]==' ')
  18.         {
  19.             if(k%2==0)
  20.             {
  21.                 s[i-k+1]='#';
  22.                 strcpy(s+i-k+2,s+i+1);
  23.                 ok=1;
  24.             }
  25.             i-=k-1;
  26.             k=-1;
  27.         }
  28.     }
  29.  
  30.     if(ok)
  31.         cout << s;
  32.     else
  33.         cout << "nu exista";
  34.  
  35.     return 0;
  36.  
  37. }
Add Comment
Please, Sign In to add comment