diff --git a/2207/C语言同步练习源码/2.循环结构-10.c b/2207/C语言同步练习源码/2.循环结构-10.c new file mode 100644 index 0000000..589db77 --- /dev/null +++ b/2207/C语言同步练习源码/2.循环结构-10.c @@ -0,0 +1,14 @@ +#include + +int main(){ + int x; + while(1){ + scanf("%d", &x); + if(x == 0){ + break; + } + printf("%d:%s\n", x, (x%5==0&&x%7==0?"Yes":"No")); + } + + return 0; +} diff --git a/2207/C语言同步练习源码/2.循环结构-8.c b/2207/C语言同步练习源码/2.循环结构-8.c new file mode 100644 index 0000000..6cd5ffc --- /dev/null +++ b/2207/C语言同步练习源码/2.循环结构-8.c @@ -0,0 +1,17 @@ +#include + +int main(){ + int i, j, k; + + for(i=0;i<=3;i++){ + for(j=1;j<=5;j++){ + for(k=0;k<=6;k++){ + if(i+j+k==8){ + printf(":%d :%d :%d\n", i, j, k); + } + } + } + } + + return 0; +} diff --git a/2207/C语言同步练习源码/2.循环结构-9.c b/2207/C语言同步练习源码/2.循环结构-9.c new file mode 100644 index 0000000..b71e9ee --- /dev/null +++ b/2207/C语言同步练习源码/2.循环结构-9.c @@ -0,0 +1,19 @@ +#include + +int main(){ + int num, n=2, first = 1; + scanf("%d", &num); + + printf("%d=",num); + while(num > 1){ + if(num%n==0){ + first?printf("%d", n):printf("*%d", n); + first=0; + num/=n; + }else{ + n++; + } + } + + return 0; +} diff --git a/2207/C语言同步练习答案.md b/2207/C语言同步练习答案.md index 56e2a32..2bfd9e0 100644 --- a/2207/C语言同步练习答案.md +++ b/2207/C语言同步练习答案.md @@ -361,6 +361,23 @@ int main(){ ![image-20250220231027969](https://yp.smallkun.cn/markdown/image-20250220231027969.png!compress) ```c +#include + +int main(){ + int i, j, k; + + for(i=0;i<=3;i++){ + for(j=1;j<=5;j++){ + for(k=0;k<=6;k++){ + if(i+j+k==8){ + printf("红:%d 白:%d 黑:%d\n", i, j, k); + } + } + } + } + + return 0; +} ``` ### 循环结构-9 @@ -368,6 +385,25 @@ int main(){ ![image-20250220231034218](https://yp.smallkun.cn/markdown/image-20250220231034218.png!compress) ```c +#include + +int main(){ + int num, n=2, first = 1; + scanf("%d", &num); + + printf("%d=",num); + while(num > 1){ + if(num%n==0){ + first?printf("%d", n):printf("*%d", n); + first=0; + num/=n; + }else{ + n++; + } + } + + return 0; +} ``` ### 循环结构-10 @@ -375,6 +411,20 @@ int main(){ ![image-20250220231039716](https://yp.smallkun.cn/markdown/image-20250220231039716.png!compress) ```c +#include + +int main(){ + int x; + while(1){ + scanf("%d", &x); + if(x == 0){ + break; + } + printf("%d:%s\n", x, (x%5==0&&x%7==0?"Yes":"No")); + } + + return 0; +} ``` ---