#include<stdio.h>
#define N 5 //定义5个学生
struct Student
{
int num;//学号
char name[20];//姓名
double score[3];//三门成绩
double aver;//平均数
int year;//年
int month;//月
int day;//日
};
int main()
{
void input(struct Student stu[]); //输入数据
void average(struct Student stu[]); //平均值
void sort(struct Student stu[]);//降序输出
int days(struct Student student);//计算
struct Student stu[N], * p = stu;
input(p);
int choice;
int m;
printf("Input each students's information\n");
/*显示主菜单*/
while (1)
{
printf("===============the Score Processing System============================\n");
printf("1,print each student's average\n");
printf("2,order the students by student's average decreasingly\n");
printf("3,printf brithday of student\n");
printf("======================================================================\n");
printf("Please choose (1~3):\n");
scanf("%d",&choice);//输入数字
switch (choice)
{
case 1:
average(p); break;
case 2:
sort(p); break;
case 3:
printf("请输入第几名同学的生日\t");
scanf("%d", &m);
printf("该同学的学号:%d ,名字:%s 生日 :%d年%d月%d日,本年第%d天\n", stu[m-1].num, stu[m-1].name, stu[m-1].year, stu[m-1].month, stu[m-1].day, days(stu[m-1]));
default:
break;
}
}
return 0;
}
void input(struct Student stu[])
{
int i;
printf("请输入各学生的信息:\n");
for (i = 0; i < N; i++)
{
printf("学号 姓名 3门课成绩 生日\t");
scanf("%d %s %lf %lf %lf\n %d %d %d", &stu[i].num, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2], &stu[i].year, &stu[i].month, &stu[i].day);
stu[i].aver = (stu[i].score[0] + stu[i].score[1] + stu[i].score[2]) / 3.0;
printf("\n");
}
}
void average(struct Student stu[])//计算平均数
{
for (int i = 0; i < N; i++)
{
stu[i].aver = (stu[i].score[0] + stu[i].score[1] + stu[i].score[2]) / 3.0;
printf("学号:%d 姓名: %s 平均成绩:%4.2lf", stu[i].num, stu[i].name, stu[i].aver);
}
}
void sort(
利用结构体录入学生的所有数据(学号,姓名,三门课程成绩,生日),选择性输出 包括(所有学生平均分,查看排名,生日,查询学生信息)四个选项
改良版算法效果图展示
最新推荐文章于 2024-01-07 19:16:46 发布
博客展示了改良版算法的效果图,虽未详细说明算法内容,但突出了改良版的成果呈现,与信息技术领域的算法相关。

最低0.47元/天 解锁文章
1102

被折叠的 条评论
为什么被折叠?



