题解 | #空心三角形图案#
空心三角形图案
http://www.nowcoder.com/practice/2ccc5fca423e47f0b622fe6f151cfab4
#include<stdio.h>
int main() {
int n;
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; i++) { //外循环行
for (int j = 0; j < n; j++) { //内循环列
if (i == n - 1 || j == 0 || i == j) printf("* ");
else printf(" ");
}
printf("\n");
}
}
return 0;
}
int main() {
int n;
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; i++) { //外循环行
for (int j = 0; j < n; j++) { //内循环列
if (i == n - 1 || j == 0 || i == j) printf("* ");
else printf(" ");
}
printf("\n");
}
}
return 0;
}