利用结构体录入学生的所有数据(学号,姓名,三门课程成绩,生日),选择性输出 包括(所有学生平均分,查看排名,生日,查询学生信息)四个选项

博客展示了改良版算法的效果图,虽未详细说明算法内容,但突出了改良版的成果呈现,与信息技术领域的算法相关。
#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(
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值