From eff87ae2142893e509b88a0bfc847f6d3afb5eb8 Mon Sep 17 00:00:00 2001 From: pvkyt5ngb Date: Fri, 10 Nov 2023 11:58:45 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E6=AD=A5=E9=AA=A4=E4=BA=8C.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 步骤二.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 步骤二.c diff --git a/步骤二.c b/步骤二.c new file mode 100644 index 0000000..9345987 --- /dev/null +++ b/步骤二.c @@ -0,0 +1,25 @@ +#include +int main() { + int student_id[3]; + float math_score[3], physics_score[3], english_score[3], total_score[3]; + + // Input student information + for (int i = 0; i < 3; i++) { + printf("Enter student %d's ID: ", i + 1); + scanf("%d", &student_id[i]); + printf("Enter student %d's math score: ", i + 1); + scanf("%f", &math_score[i]); + printf("Enter student %d's physics score: ", i + 1); + scanf("%f", &physics_score[i]); + printf("Enter student %d's english score: ", i + 1); + scanf("%f", &english_score[i]); + total_score[i] = math_score[i] + physics_score[i] + english_score[i]; + } + + // Output student information + for (int i = 0; i < 3; i++) { + printf("%d %.1f %.1f %.1f %.1f\n", student_id[i], math_score[i], physics_score[i], english_score[i], total_score[i]); + } + + return 0; +}