#include <stdio.h>
#include <string.h>
struct score_st
{
int id;
char name[20];
int math;
int chinese ;
};
struct node_st
{
struct score_st data ;
struct node_st *next ;
};
struct node_st* list_insert(struct node_st*list,struct score_st *data)
{
struct node_st *new ;
new=malloc(sizeof(*new));
if(NULL==new)
{
return NULL;
}
new->data = *data ;
new->next =NULL ;
new->next = list ;
list =new ;
return list ;
}
void list_show(struct node_st*list)
{
struct node_st *cur ;
for(cur=list;NULL!=cur ;cur=cur->next)
{
printf("%d %s %d %d\n",cur->data.id,cur->data.name,cur->data.math,
cur->data.chinese);
}
}
int main () {
if(1)
{
int i ;
struct node_st *list=NULL;
struct score_st tmp;
for(i = 0 ; i< 7 ; i++)
{
tmp.id = i ;
snprintf(tmp.name,20,"stu%d",i);
tmp.math = rand()%100;
tmp.chinese =rand()%100;
list = list_insert(list,&tmp);
}
list_show(list);
}
return 0;
}