#include<stdio.h>
#include<stdlib.h>
typedef struct girl{
char name[20];
int classnumber;
int number;
}girl;
typedef struct stu{
girl data;
struct stu* next;
}stu;
//创建链表
stucreatlink(){
stu headlink=(stu*)malloc(sizeof(stu));
headlink->next =NULL;
return headlink;
}
//创建链接
stu creatnewnode(girl data){
stu newnode=(stu*)malloc(sizeof(stu));
newnode->data =data;
newnode->next =NULL;
return newnode;
}
//从头插入链表
void insert(stuheadlink,girl data){
stu newnode =creatnewnode(data);
newnode->next =headlink->next ;
headlink->next =newnode;
}
//打印链表
void printlink(stu* headlink){
stu* p=headlink->next ;
while(p->next !=NULL){
printf("%s\t%d\t%d\n",p->data.name ,p->data.classnumber ,p->data.number );
p=p->next ;
}
}
//搜索连节
/struct/
void seeklink(stu *headlink,char name){
stu p=headlink->next ;
while(p->data.name !=name){
p=p->next ;
}
printf("%s\t%d\t%d\n",p->data.name ,p->data.classnumber ,p->data.number );
}
//删除链表
void deletelink(stu* headlink, girl data ){
stu* p=headlink;
stu* beforep=headlink->next;
while(p!=NULL){
if(p->data.name !=data.name )
beforep=p;
p=p->next ;
break;
}
beforep->next =p->next ;
free(p);
}
int main (){
int i=0;
girl g;
stu*head=creatlink();
for(i=0;i<5;i++){
scanf("%s%d%d",g.name ,g.classnumber ,g.number );
insert(head,g);
}
printlink(head);
return 0;
}