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; +}