作者: 许庭洲 时间: 2012-9-24 17:03
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 倒等腰三角形
{
calss Program
{
static void Main(string[] args)
{
int intNumber;
Console.Write("请输入显示的行数:");
string number = Console.ReadLine();
bool IsNum = int.TryParse(number, out intNumber);
if (!IsNum)
{
Console.Write("请不要输入非法数字!");
}
else if (intNumber < 3 || intNumber > 21)
{
Console.Write("输入的数据最小为3,最大为21!");
}
else
{
for (int i = intNumber; i > 0; i--)
{
//循环空格
for (int j = 0; j < intNumber - i; j++)
{
Console.Write(" ");
}
//循环图形
for (int k = 2 * i - 1; k > 0; k--)
{
Console.Write("*");
}