We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
``c #include <stdio.h> struct student { int id; // 学号 float score; // 成绩 } Student; void input_students(Student* students, int n) { for (int i = 0; i < n; i++) { printf("请输入第%d个学生的学号: ", i + 1); scanf("%d", &students[i].id); printf("请输入%d的考试成绩: ", students[i].id); scanf("%f", &students[i].score); } } void sort_students(Student* students, int n) { for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (students[j].score < students[j + 1].score) { Student temp = students[j]; students[j] = students[j + 1]; students[j + 1] = temp; } } } } loat calculate_avg_score(Student* students, int n) { float total_score = 0.0;` for (int i = 0; i < n; i++) { total_score += students[i].score; } return total_score / n; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
``c
#include <stdio.h>
struct student {
int id; // 学号
float score; // 成绩
}
Student;
void input_students(Student* students, int n) {
for (int i = 0; i < n; i++) {
printf("请输入第%d个学生的学号: ", i + 1);
scanf("%d", &students[i].id);
printf("请输入%d的考试成绩: ", students[i].id);
scanf("%f", &students[i].score);
}
}
void sort_students(Student* students, int n) {
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (students[j].score < students[j + 1].score) {
Student temp = students[j];
students[j] = students[j + 1];
students[j + 1] = temp;
}
}
}
}
loat calculate_avg_score(Student* students, int n) {
float total_score = 0.0;`
for (int i = 0; i < n; i++) {
total_score += students[i].score;
}
return total_score / n;
}
The text was updated successfully, but these errors were encountered: