From 96f108a63ac0b79a24cbd41a562f5123c7346e3e Mon Sep 17 00:00:00 2001 From: pi2o8m7nv <985803854@qq.com> Date: Sun, 20 Feb 2022 11:47:48 +0800 Subject: [PATCH] ADD file via upload --- 菱形打印.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 菱形打印.c diff --git a/菱形打印.c b/菱形打印.c new file mode 100644 index 0000000..15328d8 --- /dev/null +++ b/菱形打印.c @@ -0,0 +1,30 @@ +#include + +int main() +{ + int i,j,n; + scanf("%d",&n); + int k=(n+1)/2; + for(i=1;i<=k;i++){ + for(j=1;j<=n-2*i+1;j++){ + printf(" "); + } + for(j=1;j<=2*i-1;j++){ + printf("* "); + } + printf("\n"); + } + for(i=n-k;i>=1;i--){ + for(j=1;j<=n-2*i+1;j++){ + printf(" "); + } + for(j=1;j<=2*i-1;j++){ + printf("* "); + } + printf("\n"); + } + + return 0; +} + +