[CODE][CODE]#include <stdio.h>
#include <string.h>
struct list
{char name[20];
int mark[20];
struct list *link;};
typedef struct list LIST;
output(LIST *head)
{ LIST *p,*q;int i=0;
p=head->link;
while(p!=NULL)
{ printf("%2d:%s %4d\n",++i,p->name,p->mark);
q=p;p=p->link;free(q);}}
main()
{ int i=0,flag=1,mark;
char name[20];LIST *head,*p,*q;
head=(LIST*)malloc(sizeof(LIST));
strcpy(head->name,NULL);
head->link=NULL;
printf("Input student:\n");
do
{printf("NO.%2d:",++i);
gets(name);scanf("%d",mark);
if(strlen(name)==0)flag=0;
else
{ p=(LIST*)malloc(sizeof(LIST));
strcpy(p->name,name);
p->mark=mark;
q=head;
while(q->link!=NULL)
if(strcmp(p->name,p->link->name)>0)break;
else q=q->link;p->link=q->link; q->link=p; }
}while(flag);
printf("Output:\n");
output(head);
}
是红颜色的那行出错误了!!