[英]How i can display a few elements from two dimensional array in one line?
I'm trying to display an array in the form of a table, as I do in c ++, but it doesn't work correctly. 我正在尝试以表格形式显示数组,就像在c ++中一样,但是无法正常工作。
I was trying some format parameters on WriteLine(String, Object[]) syntax - "\\n" or "\\b", but when i use some parameter, cmd doesn't displaying anything. 我在WriteLine(String,Object [])语法上尝试了一些格式参数-“ \\ n”或“ \\ b”,但是当我使用某些参数时,cmd不会显示任何内容。
C# code which currently I'm trying. 我目前正在尝试的C#代码。
for (int i = 0; i < 25; i++)
{
for (int j = 0; j < 25; j++)
{
Console.WriteLine(Map[i, j]);
}
Console.WriteLine(" ");
}
C++ code which I'm rewriting to C#. 我正在重写为C#的C ++代码。
for (int i = 0; i < 25; i++)
{
for (int j = 0; j < 25; j++)
{
cout << tab[i][j];
}
cout << endl;
}
What I'm expecting: 我期望的是:
0 1 2 3 4 5 6 7 8 9 10 1 1 2 3 4 5 6 7 8 9 10 2 1 2 3 4 5 6 7 8 9 10 3 1 2 3 4 5 6 7 8 9 10 4 1 2 3 4 5 6 7 8 9 10 5 1 2 3 4 5 6 7 8 9 10 6 1 2 3 4 5 6 7 8 9 10 7 1 2 3 4 5 6 7 8 9 10 8 1 2 3 4 5 6 7 8 9 10 9 1 2 3 4 5 6 7 8 9 10 10 1 2 3 4 5 6 7 8 9 10
What I'm getting (without format parameter): 我得到了什么(没有format参数):
0 1 2 3 4 5 6 7 8 9 10 1 2 3 ...
( It's my first post ) (这是我的第一篇文章)
Just you made a little mistake Console.WriteLine
instead of Console.Write
只是您犯了一个小错误Console.WriteLine
而不是Console.Write
for (int i = 0; i < 25; i++)
{
for (int j = 0; j < 25; j++)
{
Console.Write(Map[i, j]);
}
Console.WriteLine();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.