Advertisement
Eddie_1337

bac 2017 sub 3 ex 3

Sep 14th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int v[100];
  6.  
  7. int duplicare(int n) {
  8.     int c = 0, i = 0;
  9.     while (n != 0) {
  10.         c++; i++;
  11.         v[i] = n % 10;
  12.         n /= 10;
  13.     }
  14.     for (i = c; i >= 1; i--) {
  15.         n = n * 10 + v[i];
  16.         if(v[i] % 2 == 0)
  17.             n = n * 10 + v[i] / 2;
  18.     }
  19.     return n;
  20. }
  21.  
  22. int main () {
  23.     int n;
  24.     cin >> n;
  25.     cout << duplicare(n);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement