我正在做一个简单的c#练习.这就是问题:编写一个名为SquareBoard的程序,它使用两个嵌套的for循环显示以下n×n(n = 5)模式.这是我的代码:
Sample output:
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
for (int row = 1; row <=5; row++) {
for (int col = 1;col <row ; col++)
{
Console.Write("#");
}
Console.WriteLine();
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用.任何人都可以帮助我.谢谢..
int n = 5;
for (int row = 1; row <= n; row++) {
for (int col = 1;col <= n; col++) {
Console.Write("# ");
}
Console.WriteLine();
}
Run Code Online (Sandbox Code Playgroud)
那样的东西?
| 归档时间: |
|
| 查看次数: |
7968 次 |
| 最近记录: |