[2017年整理]C语言结构体实验报告

《高级语言程序设计》实验报告实验序号:8 实验项目名称:结构体
四、分析与讨论河北科技大学学报
上机实践结果进行分析,上机的心得体会。
1. #include<stdio.h>
struct student
{
int num;
char name[20];
char classname[20];
float score[3];
核糖体蛋白float aver_score;
}stu[5];
void input()
{
上海冶金矿山机械厂
int i;
for(i=1;i<6;i++)
{ printf("第%d个同学",i);
printf("请输入学号名字班级三门课程成绩:\n");
scanf("%d %s %s %f %f %f",&stu[i].num,stu[i].name,stu[i].classname,&stu[i].score[1],&stu [i].score[2],&stu[i].score[3]);
}
};
void averagescore()
{
int i;
for(i=1;i<=5;i++)
stu[i].aver_score=((stu[i].score[1]+stu[i].score[2]+stu[i].score[3])/3);
printf("平均成绩:");
for(i=1;i<6;i++)
printf("第%d个同学的平均成绩%f:\n",i,stu[i].aver_score);
printf("\n");
};
void max()
{
int i,k=0;
float temp=stu[1].aver_score;
浙江林学院学报
for(i=2;i<=5;i++)
if(stu[i].aver_score>temp) {temp=stu[i] .aver_score;k=i;};
printf("成绩最好的同学:\n");
printf("%d %s %s %4.2f %4.2f %4.2f %4.2f\n",风胸
stu[k].num,stu[k].name,stu[k].classname,stu[k].score[1],stu[k].score[2],stu[k].score[3],stu[k].aver _score);设备管理系统
};
void main()
{
input();
averagescore();
max();
}
2.#include <stdio.h>
struct worker
{
char name[20];
int workyear;
float salary;
}work[5];
void input()
{
int i;
for(i=1;i<=5;i++)
{
printf("第%d个工人:",i);
printf("请输入名字工作年限工资总额:\n");
scanf("%s %d %f",&work[i].name,&work[i].workyear,&work[i].salary);

本文发布于:2024-09-22 11:34:04,感谢您对本站的认可!

本文链接:https://www.17tex.com/xueshu/361162.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:实验   名字   学报   上机
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议