c语言对学生进行分组


一、问题描述

自己用c语言结构体和数组写了一个对学生简单的分类小程序,包括姓氏相同,年龄相同,身高相仿,体重相仿,运动爱好相同,喜欢的食堂相仿。自己写的比较复杂,有什么可以改善的欢迎讨论。

二、代码

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define Num 20 
typedef struct{
                //生成一个学生信息结构体 
	char name[2][Num];		//姓,名 
	int old;				//年龄 
	double height;			//身高 
	double weight;			//体重
	char sport_hobby[30];	//运动爱好 
	char canteen[30];    	//喜欢哪个食堂 
}student;
void firstname_sort(student stu[]);
void Old_sort(student stu[]);
void height_sort(student stu[]);
void weight_sort(student stu[]);
void sporthooby_sort(student stu[]);
void canteen_sort(student stu[]);
int main()
{
   
	student stu[Num]={
   {
   "chen","zhou",21,170,130,"basketball","zhongxing"},
	{
   "jiang","yuguo",22,172.23,155.4,"badminton","qianxihe"},
	{
   "wang","hong",23,180.5,149.3,"soccer","honggaoliang"},
	{
   "chen","yuqi",23,167,110,"pingpong","zhongxing"},
	{
   "xu","jing",22,158,100,"pingpong","xingyeyuan"},
	{
   "liu","qiang",21,177.5,120.5,"basketball","qianxihe"},
	{
   "yang","qinghua",19,173.5,119.6,"soccer","honggaoliang"},
	{
   "jiang","feng",20,172,108,"badminton","xingyeyuan"},
	{
   "xu","hao",19,174,119,"vollyball","qianxihe"},
	{
   "wang","qi",20,169,110,"pingpong","zhongxing"},
	{
   "chen","zhi",21,177,112,"vollyball","honggaoliang"},
	{
   "liu","li",23,185,128,"basketball","daxibei"},
	{
   "xu","chaoyang",21,177,130,"soccer","honggaoliang"},
	{
   "jiang","ke",20,183,144,"basketball","zhongxing"},
	{
   "wang","fan",22,172,140,"badminton","yansheng"},
	{
   "liu","handing",21,172,138,"soccer","yansheng"},
	{
   "yang","xiao",20,177,128,"pingpong","daxibei"},
	{
   "xu","zhong",23,182,140,"badminton","yansheng"},
	{
   "wang","keyi",19,168,100,"pingpong","qianxihe"},
	{
   "liu","dexuan",23,175,130,"basketball","zhongxing"}
	};
	int i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值