ZSTUOJ平台刷题③:Problem A.--打印金字塔

2023-03-05,,

Problem A: 打印金字塔

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 10011  Solved: 6227

Description

请编写程序输出金字塔图形。

Input

输入一个正整数n。

Output

输出n层的金字塔。

Sample Input

1
3
5

Sample Output

*
*
***
*****
*
***
*****
*******
*********
代码如下:
#include<bits/stdc++.h>
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 k=1;k<=2*i-1;k++){
cout<<"*";
}
cout<<endl;
}
} return 0;
}

ZSTUOJ平台刷题③:Problem A.--打印金字塔的相关教程结束。

《ZSTUOJ平台刷题③:Problem A.--打印金字塔.doc》

下载本文的Word格式文档,以方便收藏与打印。