我用的VC6.0代码如下
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct stud_node{
int num;
char name[20];
int score;
struct stud_node*next;
};
int main(void)
{
struct stud_node *head,*p,*tail;
int num,score,m;
char name[20];
struct stud_node *ptr;
int size=sizeof(struct stud_node);
head=tail=NULL;
printf("Input num,nameandscore:\n");
scanf("%d",&num);
while(num!=0){
scanf("%s%d",name,&score);
p=(struct stud_node*)malloc(size);
p->num=num;
strcpy(p->name,name);
p->score=score;
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
scanf("%d",&num);
}
printf("please enter m:");
scanf("%d",&m);
if(head==NULL){
printf("\n no records");
return 0;
}
for(ptr=head;ptr;ptr=ptr->next)
{
if(ptr->score>=m)
printf("%8d%20s%6d\n",ptr->num,ptr->name,ptr->score);
}
return 0;
}
最终结果有点问题