求c语言链表编程

来源:百度知道 编辑:UC知道 时间:2024/09/21 15:31:52
用C/C++语言实现学生信息管理系统(用链表结构);例如:对学生信息实现新增、删除、查询等管理操作,学生信息包括:学号、姓名、性别、年龄等
要可以运行的

简单写了个!!看看运行一下

#include<iostream>
#include<conio.h>
using namespace std;
#define LENGTH 20
#define OK 1
#define ERROR 0

typedef long LElemType; /*学号变量类型*/
typedef int IElemType; /*成绩变量类型*/
typedef char CElemType;

typedef int Status; /*返回值的类型*/

typedef struct student
{
LElemType num;
CElemType name[LENGTH];
CElemType sex[LENGTH];
IElemType age;
student *next;

}node;

typedef struct LIST
{
node *head,*tail;

}link;

Status Init(link *s)
{
s->head = s->tail = (node *)malloc(sizeof(node)); /*头结点*/
if(NULL == s->head)
{
cout<<"分配失败!"<<endl;
return ERROR;
}
s->head->num = 0; /*头节点的学号用来放置节点个数*/
s->head->next = NULL;
return OK;
}

node *MakeNode(int i) /*生成存放学生信息的节点*/
{
no