From ff53142ba135d12836c7c0344bee99dd846c98c4 Mon Sep 17 00:00:00 2001 From: smallkun Date: Fri, 28 Feb 2025 08:41:06 +0800 Subject: [PATCH] Auto commit --- 2207/C语言同步练习源码/3.数组-1.c | 21 ++++++++++ 2207/C语言同步练习源码/3.数组-2.c | 39 +++++++++++++++++++ 2207/C语言同步练习源码/3.数组-3.c | 8 ++++ 2207/C语言同步练习答案.md | 65 +++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 2207/C语言同步练习源码/3.数组-1.c create mode 100644 2207/C语言同步练习源码/3.数组-2.c create mode 100644 2207/C语言同步练习源码/3.数组-3.c diff --git a/2207/C语言同步练习源码/3.数组-1.c b/2207/C语言同步练习源码/3.数组-1.c new file mode 100644 index 0000000..dd13e8a --- /dev/null +++ b/2207/C语言同步练习源码/3.数组-1.c @@ -0,0 +1,21 @@ +#include + +int main(){ + int num[30], i, j; + float result[6]; + for(i=0;i<30;i++){ + num[i] = 2+2*i; + } + + for(i=0;i<30;i+=5){ + result[i/5] = (num[i]+ num[i+1] + num[i+2] + num[i+3] + num[i+4])/5.0; + } + + for(i=0;i<6;i++){ + printf("%.2f ", result[i]); + } + printf("\n"); + + return 0; +} + diff --git a/2207/C语言同步练习源码/3.数组-2.c b/2207/C语言同步练习源码/3.数组-2.c new file mode 100644 index 0000000..f7e774d --- /dev/null +++ b/2207/C语言同步练习源码/3.数组-2.c @@ -0,0 +1,39 @@ +#include + +int fib(int n){ + if(n== 0 || n==1){ + return 1; + } + return fib(n-1) + fib(n-2); +} + +int main(){ + int num[15], i; + + for(i=0;i<15;i++){ + num[i] = fib(i); + } + + for(i=0;i<15;i++){ + printf("%d ", num[i]); + } + printf("\n"); + + return 0; +} + +/* +int main(){ + int num[15] = {1, 1}, i; + + for(i=2;i<15;i++){ + num[i] = num[i-1] + num[i-2]; + } + for(i=0;i<15;i++){ + printf("%d ", num[i]); + } + printf("\n"); + + return 0; +} +*/ diff --git a/2207/C语言同步练习源码/3.数组-3.c b/2207/C语言同步练习源码/3.数组-3.c new file mode 100644 index 0000000..292198a --- /dev/null +++ b/2207/C语言同步练习源码/3.数组-3.c @@ -0,0 +1,8 @@ +#include + +int main(){ + + + return 0; +} + diff --git a/2207/C语言同步练习答案.md b/2207/C语言同步练习答案.md index 2bfd9e0..f1e3ceb 100644 --- a/2207/C语言同步练习答案.md +++ b/2207/C语言同步练习答案.md @@ -435,18 +435,83 @@ int main(){ ![image-20250220231426147](https://yp.smallkun.cn/markdown/image-20250220231426147.png!compress) +```c +#include +int main(){ + int num[30], i, j; + float result[6]; + for(i=0;i<30;i++){ + num[i] = 2+2*i; + } + + for(i=0;i<30;i+=5){ + result[i/5] = (num[i]+ num[i+1] + num[i+2] + num[i+3] + num[i+4])/5.0; + } + + for(i=0;i<6;i++){ + printf("%.2f ", result[i]); + } + printf("\n"); + + return 0; +} + +``` ### 数组-2 ![image-20250220231434409](https://yp.smallkun.cn/markdown/image-20250220231434409.png!compress) +```c +#include +int fib(int n){ + if(n== 0 || n==1){ + return 1; + } + return fib(n-1) + fib(n-2); +} + +int main(){ + int num[15], i; + + for(i=0;i<15;i++){ + num[i] = fib(i); + } + + for(i=0;i<15;i++){ + printf("%d ", num[i]); + } + printf("\n"); + + return 0; +} + +/* +int main(){ + int num[15] = {1, 1}, i; + + for(i=2;i<15;i++){ + num[i] = num[i-1] + num[i-2]; + } + for(i=0;i<15;i++){ + printf("%d ", num[i]); + } + printf("\n"); + + return 0; +} +*/ +``` ### 数组-3 ![image-20250220231441384](https://yp.smallkun.cn/markdown/image-20250220231441384.png!compress) +```c +``` + ### 数组-4