QZHY-HTX / Data-Structure

泉州海洋职业学院信息工程学院2023-2024学年第二学期数据结构课程仓库
MIT License
6 stars 9 forks source link

陈炳勋2302580001 #14

Open guhunlongmo opened 7 months ago

guhunlongmo commented 7 months ago

include

struct Student { int id; float score; };

bool compareScores(const Student &a, const Student &b) { return a.score > b.score; }

include< stdio.h>

struct stu { char id[20]; float score; }; int main(){ struct stu student[5] ={ {“10001”,98},{“10002”,83},{“10003”,44},{“10004”,34},{“10005”,67} }; const int n = 5; struct stu temp;// int i,j,k; for(i = 0;I<n-1;i++){ k = i; for(j = i + 1;J<N;j++){ if(student[j].score > student[k].score) k = j; temp = 学生[k]; student[k] = 学生[i]; student[i] = 临时; } } float avg,sum;avg:平均数;sum: int lower_stu_num = 0;lower_stu_num: for(i = 0;i<n;i++){ sum += student[i].score; if(student[i].score <=60.0) lower_stu_num +=1; } 平均 = 总和 / n;

输出 for(i = 0;i<n;i++) printf(“%s %.2f\n”,student[i].id,student[i].score); printf(“%.2f %d”,平均,lower_stu_num); return 0; }

QZHY-HTX commented 7 months ago

你的 C 语言为什么还有中文关键字?