用链表编写C程序(不是C++)学生信息

来源:百度知道 编辑:UC知道 时间:2024/05/19 15:13:41
要求:1。学生信息中包含姓名、学号、成绩
2。能对链表进行插入、删除、求长度的操作

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
typedef int ElemType;

typedef struct LNode {
ElemType number;
ElemType result;
struct LNode *next;
}linklist,*link;

/*构造链表*//////////////////////////////////////
void IinitList(link &L)
{
if(L)delete L;
L= (link)malloc(sizeof(LNode)) ;
if (!L) exit(1);
L->next=NULL;
cout<<"数据已经建立\n";
}

/////////////////////////////////////////////////////
////*显示数据*///////// ////////////////////////////////
void show(link l)
{ link p; int j;
p=l;j=0;
cout<<"数据的值为:\n";
while(p->next)
{
cout<<p->next->number<<" "<<p->next->result<<endl;
p=p->next;
}
}
//////////////////////// /////////////////////////////////
//////销毁链表////// /////////////////////////////////////