#include<bits/stdc++.h>
using namespace std;
struct student{
char name[20];
double score[3];
double stuavg[5];
}stu[5];
void input(){
for(int i=0;i<5;i++){
cout<<"please input the student's name"<<endl;
cin>>stu[i].name;
cout<<"please input the student's scores for the three cources"<<endl;
cin>>stu[i].score[0]>>stu[i].score[1]>>stu[i].score[2];
}
}
void cal1(struct student *stu){//计算每个学生的平均分
for(int i=0;i<5;i++){
stu[i].stuavg=(stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3.0;
printf("NO %d 's avrage score is %lf",i+1,stu[i].stuavg);
}
}
void cal2(struct student *stu){//计算每门课的平均分
double courseavg[3];
for(int i=0;i<3;i++){
for(int j=0;j<5;j++){
courseavg[i]=stu[j].score[0];
courseavg[i]/=5.0;
}
printf("The average score of this course is %lld",courseavg[i]);
}
}
void beststu(){
int i;
for(i=0;i<4;i++){
if(stu[i].stuavg<stu[i++].stuavg){
stu[i].stuavg=stu[i++].stuavg;
int k;
i=k;
}
}
cout<<stu[i].name<<endl;
cout<<stu[i].score[0]<<endl;
cout<<stu[i].score[1]<<endl;
cout<<stu[i].score[2]<<endl;
}
int main(){
input();
cal1();
cal2();
beststu();
}
c++结构体输出5个学生平均成绩和3科平均成绩以及平均分最高的学生数据 编译不通过 不知道哪里错了 想知道怎么改
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答
相关推荐 更多相似问题
点击登录
提问题
悬赏问题
- ¥30 关于#网络安全#的问题:非对称加密验证
- ¥20 关于线性代数里施密特正交化和QR分解的疑问
- ¥15 matlab超类包含解析错误
- ¥15 python拖拽文件问题
- ¥15 执行import paddle代码出现错误如何解决?
- ¥15 hisat2align exited with value 137
- ¥15 寻找大学生合作开发软件(Delphi)
- ¥30 AndroidBench&eMMC内存测试速度&Android
- ¥15 W10 文件共享失败 怎么解决
- ¥20 b站私信完整导出的方法