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
#include <stdio.h> #include <stdlib.h> strucu student { int id; int score; } void swap(struct student *a,struct student *b){ struct student temp=*a; *a=*b; *b=temp; } void bubblesort(struct student arr[],int n){ int i,j; for(i=0;j<n-i-1;j++){ if(arr[j].score>arr[j+1],score){ swap(&arr[j],&arr[j+1]); } } } void calculateStatistics(struct Student arr[], int n) { int failCount = 0; int totalScore = 0;
for (int i = 0; i < n; i++) { totalScore += arr[i].score; if (arr[i].score < 60) { failCount++; } } if (n != 0) { printf("平均成绩: %.2f\n", (float)totalScore / n); } else { printf("没有学生成绩\n"); } printf("不及格人数: %d\n", failCount);
} int main() { int n; printf("请输入学生人数: "); scanf("%d", &n);
struct Student *students = (struct Student *)malloc(n * sizeof(struct Student)); printf("请输入学生学号和成绩:\n"); for (int i = 0; i < n; i++) { printf("学号: "); scanf("%d", &students[i].id); printf("成绩: "); scanf("%d", &students[i].score); } bubbleSort(students, n); printf("按成绩从高到低排序的学生学号和成绩:\n"); for (int i = 0; i < n; i++) { printf("学号: %d, 成绩: %d\n", students[i].id, students[i].score); }
calculateStatistics(students, n); free(students); return 0;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
#include <stdio.h>
#include <stdlib.h>
strucu student {
int id;
int score;
}
void swap(struct student *a,struct student *b){
struct student temp=*a;
*a=*b;
*b=temp;
}
void bubblesort(struct student arr[],int n){
int i,j;
for(i=0;j<n-i-1;j++){
if(arr[j].score>arr[j+1],score){
swap(&arr[j],&arr[j+1]);
}
}
}
void calculateStatistics(struct Student arr[], int n) {
int failCount = 0;
int totalScore = 0;
}
int main() {
int n;
printf("请输入学生人数: ");
scanf("%d", &n);
calculateStatistics(students, n);
free(students);
return 0;
The text was updated successfully, but these errors were encountered: