Ale*_*fly 0 c# console-application
我在绘制以下方块时遇到麻烦:
* # # # # #
* * # # # #
* * * # # #
* * * * # #
* * * * * #
* * * * * *
Run Code Online (Sandbox Code Playgroud)
这是我写的方法,但它不能正常工作:
public void Draw(int width){
char asterisk = '*';
char hash = '#';
int counter = 0;
for (int h = 0; h < 6; h++) { //height?
for (int w = 0; w < width; w++) {
if (h == counter)
Console.Write (asterisk);
else
Console.Write (hash);
}
counter++;
Console.WriteLine ();
}
Console.WriteLine ();
}
Run Code Online (Sandbox Code Playgroud)
关于我应该做什么的任何建议?我知道当它是第一行时它应该只绘制一个星号,当它是第二行两个星号时等等,但我真的不知道该怎么做..请帮助.