在 ConsoleApplication 中输出自定义形状 - C#
我有这个形状,我想将其输出到 ConoleApplication Windows。
我有这段代码,但它不能按我的需要工作:
int i,j;
for(i=0;i<5;i++)
{
for(j=5-i;j>0;j--)
Console.WriteLine(" ");
for(j=0;j<=2*i;j++)
Console.WriteLine("*");
Console.WriteLine("\n");
}
提前致谢。
编辑:我很抱歉
I have this shape and I want to output it to ConoleApplication Windows.
I have this code but it doesn't work as I need :
int i,j;
for(i=0;i<5;i++)
{
for(j=5-i;j>0;j--)
Console.WriteLine(" ");
for(j=0;j<=2*i;j++)
Console.WriteLine("*");
Console.WriteLine("\n");
}
Thanks in advance.
EDIT : I am very sorry
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
众所周知,使用 LINQ 时一切都可以正常工作...那么,您是否尝试过使用 LINQ 来实现这一点?
As everyone knows, everything Just Works™ when using LINQ... so, have you tried doing it with LINQ?
像这样的东西:
它在星号之间写入空格(加上一个备用的;如果它很重要,你可以删除它)。
Something like:
which writes the spaces between asterisks (plus a spare one; you could remove that if it is important).
您刚刚使用了
WriteLine
而不是Write
这是正确的代码:
You just used
WriteLine
instead ofWrite
Here is the correct code: