题解 | #牛牛的字符菱形#
牛牛的字符菱形
https://www.nowcoder.com/practice/11a5040fa894430f9d25fda1be37ddc8
#include <stdio.h>
void KongGe(int i);
int main() {
char a;
while (scanf("%c", &a) != EOF) { // 注意 while 处理多个 case
int k = 2;
for (int j=1;j<=5;j+=2) {
KongGe(k--);
for(int g = 0;g<j;g++){
printf("%c",a);
}
printf("\n");
}
k=1;
for (int j=3;j>=1;j-=2) {
KongGe(k++);
for(int g = 0;g<j;g++){
printf("%c",a);
}
printf("\n");
}
}
return 0;
}
void KongGe (int i){
if (i==0) {
return;
}
for (int a=0; a<i; a++) {
printf(" ");
}
}

