问一个C# 很简单的嵌套循环题目

来源:百度知道 编辑:UC知道 时间:2024/05/27 18:56:35
*

***

*****

*******
怎么把这个有规律的星星用程序编出来.注意要有空行!

for (int i = 1; i < 8; i++)
{
if (i % 2 == 1)
{
for (int j = 8 - i; j < 8; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
else
{
Console.WriteLine(); //这个地方是空行如果想空2行就把这个在输入一次
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
class Start
{
static void Main(string[] args)
{
for (int i = 0; i < 5; i++) //i控制星星数
{
for (int aaa = 0; aaa < 3; aaa++)//aaa控制 空行数
Console.WriteLine("");
for (int j = 0; j < i; j++)
Console.Write("*");
}
Console.ReadLine();
}
}
}
不能运行别给分