课程记录由课程号、课程名称、学分组成,将课程记录存放在结构体数组中。请编程求出最高的课程记录(可能不止一门课程)并输出。要求:课程数、课程记录均由键盘输入。
2条回答 默认 最新
- CSDN专家-赖老师(软件之家) 2021-05-31 10:23关注
求出最高的课程记录是指考试成绩还是学分呢?
参考一下这个看看:
#define N 2 struct Student { //学号 int num; //成员变量或者一个数据项 //姓名 char name[20]; //性别 char sex; //M,F //成绩 float html; float ppt; float cyuyan; float sum; }st[N]; void input(); void display(); void main() { input(); display(); } //输入函数 void input() { int i; for(i=0;i<N;i++) { printf("请输入第%d个学生的学号,姓名,性别,html,ppt,cyuyan:",i+1); scanf("%d",&st[i].num); scanf("%s ",st[i].name); scanf("%c ",&st[i].sex); scanf("%f",&st[i].html); scanf("%f",&st[i].ppt); scanf("%f",&st[i].cyuyan); st[i].sum = st[i].html+st[i].ppt+st[i].cyuyan; } } //输出 void display() { int i; printf("学号\t姓名\t\t性别\thtml\tppt\tC语言\t总分\t平均分\n"); for(i=0;i<N;i++) { printf("%d\t%s\t%c\t%0.2f\t%0.2f\t%0.2f\t%0.2f\t%0.2f\n",st[i].num,st[i].name,st[i].sex,st[i].html,st[i].ppt,st[i].cyuyan,st[i].sum,st[i].sum/3); } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 微信小程序协议怎么写
- ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
- ¥20 怎么用dlib库的算法识别小麦病虫害
- ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
- ¥15 java写代码遇到问题,求帮助
- ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
- ¥15 有了解d3和topogram.js库的吗?有偿请教
- ¥100 任意维数的K均值聚类
- ¥15 stamps做sbas-insar,时序沉降图怎么画
- ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看