110,825
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
画三角形(1, 1, 1, 15);
Console.ReadKey();
}
private static void 画三角形(int x, int y, int a, int n)
{
begin:
for (var i = 0; i < n - 1; i++)
输出(x, y++, a++);
for (var i = 0; i < n - 1; i++)
输出(x++, y, a++);
for (var i = 0; i < n - 1; i++)
输出(x--, y--, a++);
n -= 3;
if (n > 0)
{
x++;
y += 2;
goto begin;
}
}
private static void 输出(int x, int y, int a)
{
Console.CursorLeft = x * 4;
Console.CursorTop = y * 2;
Console.Write(a);
}
}
}