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