this function run a series of numbers.
if n=3
out put is:
1,1,1
1,1,2
1,1,3
1,2,1
1,2,2
1,2,3
1,3,1
1,3,2
1,3,3
Please help me understand how the increasing process in this function works. I cann't see how the array's elemt increase their values.
Code:
void print_num(int n)
{
int times;
times=pow(n,2);
while (times--)
{
for(i=0;i<n-1;i++)
{
printf ("%d,", arr[i]);
}
printf ("%d\n",arr[i]);
if (++arr[n-1]>n)
{
arr[n-1]=1;
for(j=i-1;j>=0;j++)
if (++arr[j]>n)
arr[j]=1;
else
break;
}
}
}