#include<iostream>
using namespace std;
int main(int argc, char *argv[])
{
int n = 0;
while (true)
{
cin >> n;
for (size_t i = 1; i <= n; i++)
{
for (size_t j = 1; j <= i-1; j++)
{
cout << " ";
}
for (size_t k = 1; k <= 2*n+1-2*i; k++)
{
if (k % 2 == 0)
{
cout << "-";
}
else
{
cout << "*";
}
}
cout << endl;
}
}
system("pause");
return 0;
}
输出倒三角形
最新推荐文章于 2021-08-18 23:32:31 发布