Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void duplicare(int n, int &d) {
- int p = 1, ok = 0;
- d = 0;
- while (n) {
- if (n % 2 == 0) {
- d = (n % 10) * p + d;
- p *= 10;
- } else {
- d = (n % 10) * p + d;
- p *= 10;
- d = (n % 10) * p + d;
- p *= 10;
- ok = 1;
- }
- n /= 10;
- }
- if (!ok) {
- d = -1;
- }
- }
- int main() {
- int d;
- duplicare(23450, d);//2334550
- cout << d << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement