Hello everyone,
I'm required to print a puzzle which in the form of row*col. And my code can do that except when row and col are the same number. How can I fix that? And another question is, how can I store these values into a 2D array??? Because later on, I need to modify the position inside the puzzle.
Please help me. Many thanks!!!!!!
Console.WriteLine("size:");
int row = int.Parse(Console.ReadLine());
int col = int.Parse(Console.ReadLine());
int m = 1;
for (int i = 0; i < row; i++)
for (int j = 0; j < col; j++)
{
if (j == row)
Console.WriteLine(m+" ");
else
Console.Write(m+" ");
m++;
}
Console.ReadLine();