#include<iostream>
using namespace std;
void triangle(int n);
int main()
{
int n;
cout << "输入n: ";
cin >> n;
triangle(n);
return 0;
}
void triangle(int n)
{
int i, j;
for (i = 1; i < n; i++)
{
for (j = 1; j < 2 * n - 1; j++)
{
if (j == n + i - 1 || j == n - i + 1)
cout << "*";
else
cout << " ";
}
cout << endl;
}
for (j = 1; j < 2 * n; j++)
{
cout << "*";
}
cout << endl;
}
空心三角形
最新推荐文章于 2018-08-21 20:36:38 发布