美文网首页
12.20作业一

12.20作业一

作者: beloved0114 | 来源:发表于2018-12-26 08:14 被阅读0次

训练一:打印直角三角形

需求说明

从控制台输入直角三角形的高度(行数)

每行 * 的数目依次为1、3、5、7…

代码

Console.WriteLine("请输入直角三角形的行数:");

int a = Convert.ToInt32(Console .ReadLine ());

for (int i = 1; i <= a; i++)

{

for (int j = 0; j < 2 * i - 1; j++)

{

Console.Write("*");

}

Console.WriteLine();

}

Console.ReadKey();

}

12.20作业一

相关文章

网友评论

      本文标题:12.20作业一

      本文链接:https://www.haomeiwen.com/subject/tvyclqtx.html