Advertisement
Eksekk

K01A B

Jun 25th, 2021
881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <string>
  2.  
  3. std::string::iterator function(std::string::const_iterator a, std::string::const_iterator b, std::string::iterator wyjscie)
  4. {
  5.     while ((a + 1) != b)
  6.     {
  7.         if (*a == *(a + 1))
  8.         {
  9.             *wyjscie++ = *a;
  10.         }
  11.         else
  12.         {
  13.             *wyjscie = *a;
  14.             *(wyjscie + 1) = *(a + 1);
  15.             wyjscie += 2;
  16.         }
  17.         ++a;
  18.         if ((a + 1) == b)
  19.         {
  20.             break;
  21.         }
  22.         ++a;
  23.  
  24.     }
  25.     if ((b - a) % 2 == 1)
  26.     {
  27.         *wyjscie++ = *a;
  28.     }
  29.     return wyjscie;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement