I just started the game of fifteen ,so i thought of drawing the board in this way
char space=' ';
for(int i=15;i>=1;i--)
{
for(int j=i;j>=i-3;j--)
{
printf("%2d%c",j,space);
}
i=i-3;
printf("\n");
}
}
to get the idea .I am getting output as
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
and i am not able to replace 0 by '-'which is the requirement of the game .
i tried implementing this
#include <cs50.h>
#include <stdio.h>
int main(void)
{
char space=' ';
char hash='-';
for(int i=15;i>=1;i--)
{
for(int j=i;j>=i-3;j--)
{
printf("%2d%c",j,space);
while (j==1)
{
printf("%c",hash)
}
}
i=i-3;
printf("\n");
}
}
but this outputs infinite bunch of numbers,seems like when implementing j==1 condition, loop gets repeated, it doesn't end.