Hello!

I have to make a program that reads two numbers a and b and then displays all the numbers that can be formed by replacing the first and the last digit of b with every single digit of a.

For example,if a is 19 and b = 913 it should display the numbers:

113,911,919,913.

There is my piece of code :

I used 'na' and 'nb' to calculate the number of digits of a and b. Also,I used 2 arrays 'va[12]' and 'vb[12]' to hold the values of every digit in the number.Code:`#include<iostream>`

using namespace std;

int main()

{

int a,b,i = 0,j = 0,na = 0,nb = 0,va[12],vb[12];

cout <<"a = ";

cin >> a;

cout <<"b = ";

cin >> b;

while (a) {

va[i] = a%10;

na++;

i++;

}

while (b) {

vb[j] = b%10;

nb++;

j++;

}

for (i = na-1;i >= 0;i--) {

vb[0] = va[i];

vb[na] = va[i];

for (j = nb - 1; j >= 0;j--){

cout << vb[j] << " " ;

}

}

return 0;

}

What's wrong? It doesn't work properly...

Thanks in advance !