标签:return ret include names for nbsp out 倒三角 代码
输入正整数 n <= 20 , 输出一个 n 层的倒三角。例如, n = 5 时输出如下
#########
#######
#####
###
#
代码如下
#include<iostream>
using namespace std;
int main()
{
int n;
int num=0;
while (cin>>n)
{
num = 2*n - 1;
for (int i = 1; i <= n; i++)
{
for (int j = num; j > 0; j--)
cout<<"#";
cout<<endl;
for (int k = 1; k <= i; k++)
cout<<" ";
num = num - 2;
}
}
return 0;
}
标签:return ret include names for nbsp out 倒三角 代码
原文地址:https://www.cnblogs.com/go-alltheway/p/13338856.html