题解 | #牛牛的字符菱形#
牛牛的字符菱形
https://www.nowcoder.com/practice/11a5040fa894430f9d25fda1be37ddc8
#include <stdio.h> int main() { char ch; int i, j, k; scanf("%c", &ch); //上三角 for (i = 0; i <= 2; i++) { for (j = 2 - i; j > 0; j--) printf(" "); //打印空格 for (k = 1; k <= 2 * i + 1; k++) //字符是1,3,5递增 printf("%c", ch); printf("\n"); } //下三角颠倒 for (i = 2; i > 0; i--) { for (j = 0; j <= 2 - i; j++) printf(" "); for (k = 1; k <= 2 * i - 1; k++) printf("%c", ch); printf("\n"); } }
这种找规律的真的烦