题解 | #金字塔图案#
金字塔图案
https://www.nowcoder.com/practice/d84e8339f9444bb6b29bd3f227c8e538
#include<stdio.h>
int main(){
int n,i,j,k=1;
while(scanf("%d",&n)!=EOF){
for(i=1;i<=n;i++){
k=1;
for(j=i;j>=1;j--){
while(k<=n-j){
printf(" ");
k++;
}
if(k>n-j){
printf("*");
}
}
printf("\n");
}
}
}
int main(){
int n,i,j,k=1;
while(scanf("%d",&n)!=EOF){
for(i=1;i<=n;i++){
k=1;
for(j=i;j>=1;j--){
while(k<=n-j){
printf(" ");
k++;
}
if(k>n-j){
printf("*");
}
}
printf("\n");
}
}
}