diff --git a/2207/C语言同步练习源码/2.循环结构-7.c b/2207/C语言同步练习源码/2.循环结构-7.c new file mode 100644 index 0000000..3080245 --- /dev/null +++ b/2207/C语言同步练习源码/2.循环结构-7.c @@ -0,0 +1,16 @@ +#include + +int main(){ + + int month, total = 2, i; + scanf("%d", &month); + + for(i=1;i<=month;i++){ + if(i%3==0){ + total *= 2; + } + printf("%d:%d\n", i, total); + } + + return 0; +} diff --git a/2207/C语言同步练习答案.md b/2207/C语言同步练习答案.md index d9045c9..56e2a32 100644 --- a/2207/C语言同步练习答案.md +++ b/2207/C语言同步练习答案.md @@ -338,6 +338,22 @@ int main(){ ![image-20250220231022607](https://yp.smallkun.cn/markdown/image-20250220231022607.png!compress) ```c +#include + +int main(){ + + int month, total = 2, i; + scanf("%d", &month); + + for(i=1;i<=month;i++){ + if(i%3==0){ + total *= 2; + } + printf("%d月:%d个数\n", i, total); + } + + return 0; +} ``` ### 循环结构-8