用C#怎么输入一个空的矩形框?

balinghousheng 2009-03-08 05:14:31
必须要用循环语句
输出如下:
**********
* *
* *
* *
* *
* *
**********
...全文
127 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cppfaq 2009-03-09
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wuyi8808 的回复:]
引用楼主 balinghousheng 的帖子:
必须要用循环语句
输出如下:
**********
* *
* *
* *
* *
* *
**********



C# codefor (i = 0; i < 1; i++)
{
System.Console.WriteLine(@"**********
* *
* *
* *
* *
* *
**********");
}
[/Quote]
凶悍!
zhaigates 2009-03-08
  • 打赏
  • 举报
回复
楼上循环的不错
wuyi8808 2009-03-08
  • 打赏
  • 举报
回复
[Quote=引用楼主 balinghousheng 的帖子:]
必须要用循环语句
输出如下:
**********
* *
* *
* *
* *
* *
**********
[/Quote]

for (i = 0; i < 1; i++)
{
System.Console.WriteLine(@"**********
* *
* *
* *
* *
* *
**********");
}
zhaigates 2009-03-08
  • 打赏
  • 举报
回复
空的用空格
balinghousheng 2009-03-08
  • 打赏
  • 举报
回复
什么意思啊,不是很懂
cppfaq 2009-03-08
  • 打赏
  • 举报
回复
   internal class Program
{
private static void Main(string[] args)
{
int cols = 10;
int lines = 7;
string stars = new string('*', cols - 2);
string blanks = new string(' ', cols - 2);
string format = "*{0}*";
for(int i = 0; i < lines; i++)
{
bool isClosure = i == 0 || i == lines - 1;
Console.WriteLine(string.Format(format, isClosure ? stars : blanks));
}
Console.ReadLine();
}

}

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧