2020-03-10

#include <stdio.h>
#include<math.h>#include<stdlib.h>struct student{ double num; char name[20]; float score[4];};input(struct student arr[],int)aver(struct student arr[],int)void order(struct student arr[],int)void output(struct student arr[],int)void main(){ struct student stu[100], *p; p = stu; int n; scanf("%d", &n); input(stu,n); aver(stu,n); order(stu,n); output(stu,n);}void input(struct student arr[],int n){ for(int i = 0; i < n; i++) { arr[i].score[3] = 0.0; printf(“请输入第%d个学生的姓名,学号及英语,数学和物理成绩:\n”,i+1); scanf("%s %d %f %f %f",&arr[i].name,&arr[i].num,&arr[i].score[0],&arr[i].score[1],&arr[i].score[2]); }}void aver(struct student arr[],int n){ int i; float total[] = 0.0; float average[]; for(i = o; i < n; i++) { float total[i] = arr[i].score[0] + arr[i].score[1] + arr[i].score[2]; average[i] = total[i]/3; arr[i].score[3] = average[i]; } }void order(struct student arr[], int n){ for (int i =0;i < n ;i++ ) { struct student temp[]; if(arr[i+1].score[3] > arr[i].score[3]) { temp[] = arr[i+1]; arr[i+1] = arr[i]; arr[i] = temp[]; } }}void output(struct student arr[], int n){ for (int i = 0;i < n ;i++ ) { printf("%s %d %f %f %f %f\n",arr[i].name,arr[i].num,arr[i].score[0],arr[i].score[1],arr[i].score[2],arr[i].score[3]); }}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值