Advertisement
STANAANDREY

T 21/10/2019

Oct 21st, 2019
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <stdio.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char s[100], c[100], s1[100], s2[100];
  9.     cin >> s >> c;
  10.     s1[0] = s[0];
  11.     int n = strlen(s), n1 = 1, n2 = 0;
  12.     for (int i = 1; i < n; i++)
  13.         if (int(c[i] - '0') % 2)
  14.         {
  15.             s1[n1] = s[i];
  16.             n1++;
  17.         }
  18.         else
  19.         {
  20.             s2[n2] = s[i];
  21.             n2++;
  22.         }
  23.     s1[n1] = char(0);
  24.     s2[n2] = char(0);
  25.  
  26.     for (int i = 0; i < n2 / 2; i++)
  27.     {
  28.         char aux = s2[i];
  29.         s2[i] = s2[n2 - i - 1];
  30.         s2[n2 - i - 1] = aux;
  31.     }
  32.  
  33.     strcat(s2, s1);
  34.     cout << s2;
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement