Advertisement
Josif_tepe

Untitled

Dec 28th, 2021
1,119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <cstring>
  5. using namespace  std;
  6.  
  7. void chesel(int &a, int &b) {
  8.     int tmp_a = a;
  9.     int tmp_b = b;
  10.     int sz = 1;
  11.     while(tmp_a) {
  12.         sz *= 10;
  13.         tmp_a /= 10;
  14.     }
  15.     tmp_a = a;
  16.     int pa = 0, pb = 0;
  17.     while(tmp_a) {
  18.         int ca = tmp_a % 10;
  19.         int cb = tmp_b % 10;
  20.         if(ca % 2 == 0) {
  21.             pa = (pa * 10) + cb;
  22.             pb = (pb * 10) + ca;
  23.          }
  24.         else {
  25.             pa = (pa * 10) + ca;
  26.             pb = (pb * 10) + cb;
  27.         }
  28.         tmp_a /= 10;
  29.         tmp_b /= 10;
  30.     }
  31.     a = 0;
  32.     b = 0;
  33.     int aa = 0, bb =0 ;
  34.     while(pa) {
  35.         a = (a * 10) + (pa % 10);
  36.         pa /= 10;
  37.         aa++;
  38.     }
  39.     while(pb) {
  40.         b = (b * 10) + (pb % 10);
  41.         pb /= 10;
  42.         bb++;
  43.     }
  44.     while(aa < bb) {
  45.         aa++;
  46.         a *= 10;
  47.     }
  48.     while(bb < aa) {
  49.         bb++;
  50.         b *= 10;
  51.     }
  52.     return;
  53. }
  54. int main() {
  55.     int a, b;
  56.     cin >> a >> b;
  57.     chesel(a, b);
  58.     cout << a << " " << b << endl;
  59.     return 0;
  60. }
  61.  
  62.  
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement