From 82f4f06cb168e53315b0d207597e55e9c4988b31 Mon Sep 17 00:00:00 2001 From: pos2gra5i <2949973001@qq.com> Date: Tue, 15 Feb 2022 22:37:35 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E5=87=BD=E6=95=B0=20=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E8=8F=B1=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 函数 输出菱形 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 函数 输出菱形 diff --git a/函数 输出菱形 b/函数 输出菱形 new file mode 100644 index 0000000..22e1459 --- /dev/null +++ b/函数 输出菱形 @@ -0,0 +1,32 @@ +#include +void PrintSpace(int n) +{ + int i; + for(i=1;i<=n;i++) + printf(" "); +} +void Print(int n) +{ + int i; + for(i=1;i<=2*n-1;i++) + printf("*"); +} +int main() +{ + int n; + scanf("%d",&n); + int i; + for(i=1;i<=n;i++) + { + PrintSpace(n-i); + Print(i); + printf("\n"); + } + for(i=n-1;i>0;i--) + { + PrintSpace(n-i); + Print(i); + printf("\n"); + } + return 0; +} \ No newline at end of file