用C#编程在屏幕上输出一个n行的金字塔图案,例如,若n=5,则图案

2025-04-13 08:34:57
推荐回答(2个)
回答1:

c# asp.net 写的代码 int line=5; // 行数 也就是你说的n
//控制输出多少行
for(int i=0;i {
//输出空格
for (int x = 0; x < line-i; x++)
{
Response.Write(" ");
}
//输出星号
for(int y=0;y<2*i+1;y++)
{
Response.Write("*");
}
Response.Write( "
\n");
}

回答2:

你是要程序?还是结果?