diff --git a/【实践课内】4.循环结构1/7-1 求奇数和.c b/【实践课内】4.循环结构1/7-1 求奇数和.c new file mode 100644 index 0000000..2e19dab --- /dev/null +++ b/【实践课内】4.循环结构1/7-1 求奇数和.c @@ -0,0 +1,15 @@ +#include + +int main() { + int x, ans = 0; + + while (scanf("%d", &x), x > 0) { + if (x % 2 == 1) { + ans += x; + } + } + + printf("%d\n", ans); + + return 0; +} diff --git a/【实践课内】4.循环结构1/7-1 求奇数和.jpg b/【实践课内】4.循环结构1/7-1 求奇数和.jpg new file mode 100644 index 0000000..8e9f674 Binary files /dev/null and b/【实践课内】4.循环结构1/7-1 求奇数和.jpg differ diff --git a/【实践课内】4.循环结构1/7-2 100以内的加法.c b/【实践课内】4.循环结构1/7-2 100以内的加法.c new file mode 100644 index 0000000..68baa2c --- /dev/null +++ b/【实践课内】4.循环结构1/7-2 100以内的加法.c @@ -0,0 +1,15 @@ +#include + +int main() { + int m, n, ans = 0; + + scanf("%d%d", &m, &n); + + for (int i = m; i <= n; i++) { + ans += i; + } + + printf("%d\n", ans); + + return 0; +} diff --git a/【实践课内】4.循环结构1/7-2 100以内的加法.jpg b/【实践课内】4.循环结构1/7-2 100以内的加法.jpg new file mode 100644 index 0000000..fcf4799 Binary files /dev/null and b/【实践课内】4.循环结构1/7-2 100以内的加法.jpg differ diff --git a/【实践课内】4.循环结构1/7-3 统计学生平均成绩与及格人数.c b/【实践课内】4.循环结构1/7-3 统计学生平均成绩与及格人数.c new file mode 100644 index 0000000..47768a5 --- /dev/null +++ b/【实践课内】4.循环结构1/7-3 统计学生平均成绩与及格人数.c @@ -0,0 +1,27 @@ +#include + +int main() { + int n, count = 0, sum_score = 0; + + scanf("%d", &n); + + if (n == 0) { + printf("average = 0.0\ncount = 0\n"); + } else { + for (int i = 1; i <= n; i++) { + int score; + + scanf("%d", &score); + + sum_score += score; + + if (score >= 60) { + count++; + } + } + + printf("average = %.1lf\ncount = %d\n", (double)sum_score / n, count); + } + + return 0; +} diff --git a/【实践课内】4.循环结构1/7-3 统计学生平均成绩与及格人数.jpg b/【实践课内】4.循环结构1/7-3 统计学生平均成绩与及格人数.jpg new file mode 100644 index 0000000..cd82024 Binary files /dev/null and b/【实践课内】4.循环结构1/7-3 统计学生平均成绩与及格人数.jpg differ diff --git a/【实践课内】4.循环结构1/7-4 循环-4 的倍数.c b/【实践课内】4.循环结构1/7-4 循环-4 的倍数.c new file mode 100644 index 0000000..1c5709a --- /dev/null +++ b/【实践课内】4.循环结构1/7-4 循环-4 的倍数.c @@ -0,0 +1,19 @@ +#include + +int main() { + int n, count = 0; + + scanf("%d", &n); + + for (int i = 1; i <= n; i++) { + int x; + + scanf("%d", &x); + + if (x % 4 == 0) count++; + } + + printf("%d\n", count); + + return 0; +} diff --git a/【实践课内】4.循环结构1/7-4 循环-4 的倍数.jpg b/【实践课内】4.循环结构1/7-4 循环-4 的倍数.jpg new file mode 100644 index 0000000..632787a Binary files /dev/null and b/【实践课内】4.循环结构1/7-4 循环-4 的倍数.jpg differ