user-0 提问: PAT 乙级 1004段错误求助！

回复:
user: user-1
content: 希望对你有帮助：https://blog.csdn.net/it_xiangqiang/category_10581430.html 希望对你有帮助：https://blog.csdn.net/it_xiangqiang/category_10768339.html

user: user-2
content: #include<stdio.h> #include<stdlib.h>  #define len sizeof(struct student) struct student *creat(void);  struct student {     char name[11];     char sno[11];     int score;     struct student *next; };  int main(void) {      struct student *phead, *pcur;     struct student *pmax_stu, *pmin_stu;      phead = creat();      pcur = phead;     pmax_stu = pmin_stu = phead;     while (pcur) {         if (pcur->score > pmax_stu->score)             pmax_stu = pcur;         if (pcur->score < pmin_stu->score)             pmin_stu = pcur;         pcur = pcur->next;     }      printf("%s %s\n", pmax_stu->name, pmax_stu->sno);     printf("%s %s\n", pmin_stu->name, pmin_stu->sno); #if 0     struct student *p,*p1,*p2,*p3,*p4,*p5;     int max,min;     p=p3=p4=creat();     //只有一个同学时     p5=p4;     p4=p4->next;     /*     if(p4->name==NULL){         printf("%s %s\n",p5->name,p5->sno);         printf("%s %s\n",p5->name,p5->sno);     }     */     //最大值寻找     p1=p;     max=p->score;     p=p->next;     do{         if(max<(p->score)){             max=p->score;             p1=p;         }         p=p->next;     }while(p->next!=NULL);     //最小值寻找     p2=p3;     min=p3->score;     p3=p3->next;     do{         if(min>(p3->score)){             min=p3->score;             p2=p3;         }         p3=p3->next;     }while(p3->next!=NULL);     printf("%s %s\n",p1->name,p1->sno);     printf("%s %s\n",p2->name,p2->sno); #endif }  struct student *creat(void) {     int n,i;     struct student *head;     struct student *p1,*p2;      scanf("%d",&n);     //p2=(struct student*)malloc(len);     p1=(struct student*)malloc(len);      for(i=0;i<n;i++){         scanf("%s %s %d", p1->name,p1->sno,&p1->score);         if(i==0){             head=p1;         }         else{             p2->next=p1;         }         p2=p1;         if(i!=n-1){             p1=(struct student*)malloc(len);         }     }     p2->next=NULL;     return (head); } 供参考～  楼主考虑的比较繁琐吧，建议对比代码找一下自己的问题～

user: user-3
content: 送你：CSDN论坛新手指南

user: user-4
content: 以后不要再发截图了，直接贴代码吧，给你看帖子的人也不是编译器，看一下就可以运行出来；除非闲得无聊，一般没有人会把你的代码去打一遍的

user: user-0
content: #include<stdio.h> #include<stdlib.h> #define len sizeof(struct student) struct student *creat(void); struct student { 	char name[11]; 	char sno[11]; 	int score; 	struct student *next; }; int main(void){ 	struct student *p,*p1,*p2,*p3,*p4,*p5; 	int max,min; 	p=p3=p4=creat();     //只有一个同学时 	p5=p4; 	p4=p4->next; 	if(p4->name==NULL){ 		printf("%s %s\n",p5->name,p5->sno); 		printf("%s %s\n",p5->name,p5->sno); 	}     //最大值寻找 	p1=p; 	max=p->score; 	p=p->next; 	do{ 		if(max<(p->score)){ 		    max=p->score;	 		    p1=p; 		} 		p=p->next; 	}while(p->next!=NULL);      //最小值寻找 	p2=p3; 	min=p3->score; 	p3=p3->next; 	do{ 		if(min>(p3->score)){ 			min=p3->score; 			p2=p3; 		} 		p3=p3->next; 	}while(p3->next!=NULL); 	printf("%s %s\n",p1->name,p1->sno); 	printf("%s %s\n",p2->name,p2->sno); } struct student *creat(void) { 	int n,i; 	struct student *head; 	struct student *p1,*p2; 	scanf("%d",&n); 	p2=(struct student*)malloc(len);	 	p1=(struct student*)malloc(len); 	for(i=0;i<n;i++){ 		scanf("%s %s %d",p1->name,p1->sno,&p1->score); 		if(i==0){ 			head=p1; 		} 		else{ 			p2->next=p1; 		} 		p2=p1; 		if(i!=n-1){ 			p1=(struct student*)malloc(len); 		} 	} 	p2->next=NULL; 	return (head); }

user: user-0
content: 引用 2 楼 wowpH 的回复：送你：CSDN论坛新手指南谢谢，现在放代码

user: user-0
content: 引用 1 楼 qq_45798109 的回复：以后不要再发截图了，直接贴代码吧，给你看帖子的人也不是编译器，看一下就可以运行出来；除非闲得无聊，一般没有人会把你的代码去打一遍的谢谢前辈