I'm writing a C# console app. The "app" is a poor mans matrix (1 and 0 fall down the page).
I can't figure out how to get 1 row first, then two rows (the 1st row should now be in 2cnd place) etc.
The closest I get is just the next row in the 2d array...
This prints just the current row:
public static int col = 0;
static void PrintSingleLine()
{
for (int i = col; i <= pnms.GetLength(0) - 1;)
{
for (int j = 0; j <= pnms.GetLength(1) - 1; j++)
{
Console.Write(pnms[col, j]);
}
break;
}
col =+ 1;
}
I've modified it, and tried to get it to print out all the rows that have been printed so far +1, but I cant get it to work...
public static int coll = 0;
static void PrintRelevantLines()
{
int cnt = 0;
for (int i = coll; i <= pnms.GetLength(0) - 1;)
{
for (int j = 0; j <= pnms.GetLength(1) - 1; j++)
{
for (int k = cnt; k <= coll; k++)
{
Console.Write(pnms[k, j]);
}
}
break;
}
coll = +1;
}
Any help would be much appreciated.
Thank you
Edit 1:
As requested I will show you the wished for result.
Let's say my array has 3 rows. The values are like this:
1 0 1 0 0 1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 1
0 1 1 0 1 0 0 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1
1 0 1 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1
I would like the 1st second/or user input to print
(x) 1 0 1 0 0 1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 1
The 2nd user input to print:
(y) 0 1 1 0 1 0 0 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1
(x) 1 0 1 0 0 1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 1
The 3rd user input to print:
(z) 1 0 1 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1
(y) 0 1 1 0 1 0 0 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1
(x) 1 0 1 0 0 1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 1
Thanks for pointing out what wasn't clear. As I posed the question I though that was clear :)
Let me know if I can provide any additional info
break;seems odd, just remove itbreak;it just keeps looping indefenitly... and if there are more characters then the buffer size it should write in the next line anyway...