时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
请编写程序输出金字塔图形。
输入描述:
多个测试数据。每个测试数据输入一个整数n(1 <= n <= 9)
输出描述:
输出金字塔
示例1
输入
> 1
> 3
输出
*
*
***
*****
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n-i;j++)
{
cout<<" ";
}
for(int j=1;j<=2*i-1;j++)
{
cout<<"*";
}
cout<<endl;
}
}
return 0;
}