In: Computer Science
If you have any problem with the code feel free to comment.
Program
#include <iostream>
using namespace std;
void count( int begin[], int end[] )
{
int index, current[4] = { begin[0], begin[1], begin[2], begin[3] };
//initial print
cout << current[0] << current[1] << current[2] << current[3] << endl;
index = 3;
//infinite loop
while(1)
{
//add condition
if ( current[index] < end[index] - 1 )
{
current[index]++;
cout << current[0] << current[1] << current[2] << current[3] << endl;
index = 3;
}
//carry condition
else if ( index > 0 )
{
current[index] = begin[index];
index--;
}
//exit the loop
else
return;
}
}
int main( )
{
int begin[4] = { 0, 0, 0, 0 };
int end[4] = { 2, 3, 2, 4 };
count(begin, end);
return 0;
}
Output