匿名用户
1级
2012-12-11 回答
#include
#include
#include
#include
#define N 20000
struct Student
{
int score;
struct Student *next;
};
//创建单向键表,返回链表表头head
struct Student *CreatLink(struct Student *head ,int n)
{
int i;
struct Student *p1,*p2;
head=p1=(struct Student *)malloc(sizeof(struct Student));
if(p1 == NULL)
{
printf("Not enough memory to allocate buffer\n");
system("PAUSE");
exit(1); /* terminate program if out of memory */
}
p1->score = rand()%101;//产生随机值
p1->next=NULL;
for(i=2;i<=n;i++)
{
p2=p1;
p1=(struct Student *)malloc(sizeof(struct Student));
if(p1 == NULL)