Interleaving of numbers

We define the interleaving of two natural numbers with d digits
x = x_(d)x_(d − 1)…x₂x₁ and y = y_(d)y_(d − 1)…y₂y₁ as
x_(d)y_(d)x_(d − 1)y_(d − 1)…x₂y₂x₁y₁. For example, the interleaving of
4123 and 5679 is 45162739. Write a program that reads pairs of natural
numbers and prints their interleavings.

For the sake of practice, define and use a function

        int interleaving(int x, int y);

to compute the interleaving of two natural numbers x and y.

Input

Input consists of several pairs of natural numbers with the same number
of digits.

Output

Print the interleaving of every given pair.

Observation

To avoid overflows, no given number will have more than four digits, but
your program should not take this fact into account.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:41:48.543Z

© Jutge.org, 2006–2026.
https://jutge.org
