之前大一写的,一年前的水平
现在学习数据结构,重新拿出来看看
现在学习数据结构,重新拿出来看看
分享给大家看看
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#include<conio.h>
#include<ctype.h>
#define Esc 27
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
char class_0[20]; //班级
int num; //学号
char name[20]; //姓名
float c_prog; //c语言程序设计
float eng; //大学英语
float math; //高等数学
float avg; //平均成绩
int order; //名次
struct student *next;
};
int n; //全局变量,统计学生记录的个数
//函数声明
struct student *create();
void Output(struct student *head);
struct student *Delete(struct student *head, int num);
struct student *insert(struct student *head, struct student *stud);
struct student *Lookup(struct student *head, int num);
struct student *Modify(struct student *head, int num);
float Statistic(struct student *p);
struct student *order(struct student *head);
void start();
void goon();
void exit();
//创建链表,输入学生信息
struct student *create()
{
struct student *head;
struct student *pl;
n=0;
pl=(struct student*) malloc(LEN);
printf("\n\n\t请输入学生的信息: \n");
printf("\t输入格式为:(每输入一项回车,以学号为0退出!)\n");
printf("\t请输入学生学号:");
scanf("%d",&pl->num );
printf("\t请输入学生姓名:");
scanf("%s",&pl->name );
printf("\t请输入学生班级:");
scanf("%s",&pl->class_0 );
printf("\n");
printf("\t请输入程序设计成绩:");
scanf("%f",&pl->c_prog );
printf("\t请输入大学英语成绩:");
scanf("%f",&pl->eng );
printf("\t请输入高等数学成绩:");
scanf("%f",&pl->math );
printf("\n");
head=NULL;
while(pl->num !=0)
{
pl->avg =Statistic(pl); //求pl的平均值
head=insert(head,pl); //创建链表
pl=(struct student*)malloc(LEN);
printf("\n\t如果你想结束输入,请输入 0 !\n\n");
printf("\t请输入学号:");
scanf("%d",&pl->num );
if(pl->num ==NULL) //控制是否退出
continue;
printf("\t请输入学生姓名:");
scanf("%s",&pl->name );
printf("\t请输入学生班级:");
scanf("%s",&pl->class_0 );
printf("\n");
prin