|  | 
 
| 
本帖最后由 wdwhszw 于 2021-2-4 09:43 编辑
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册  
 请问一下我的代码提示的那个错误定义到底哪里有问题
 
 
 #include<stdio.h>
 #include<stdlib.h>
 #include<malloc.h>
 #define LEN sizeof(struct nb)
 
 
 struct nb
 {
 long xh;
 float cj;
 struct nb *next;
 };
 
 
 void sc(struct nb *head)
 {
 struct nb *b;
 b=head;
 if(head)
 {
 do
 {
 printf("%d   %f",b->xh,b->cj);
 b=b->next;
 }while(b);
 }
 }
 
 
 struct nb *p()
 {
 int n=0;
 struct nb *head,*p1,*p2;
 p1=p2=(struct nb *)malloc(LEN);
 head=NULL;
 scanf("%d,%f",&p1->xh,&p1->cj);
 while(p1->xh)
 {
 n=n+1;
 if(n==1)
 head=p1;
 else
 p2->next=p1;
 p2=p1;
 p1=(struct nb *)malloc(LEN);
 scanf("%d,%f",&p1->xh,&p1->cj);
 }
 p2->next=NULL;
 return head;
 }
 
 
 struct nb *del(struct nb *head,long num)
 {
 struct nb *p1,*p2;
 if(head==NULL)
 {
 printf("null");
 goto END;
 }
 p1=head;
 while(num!=p1->xh&&p1->next!=NULL)
 {
 p2=p1;
 p1=p1->next;
 }
 if(p1->xh==num)
 {
 if(p1==head)
 head=p1->next;
 else
 p2->next=p1->next;
 }
 else
 printf("not found");
 
 END:
 return head;
 }
 
 
 struct nb *xd(struct nb *head)
 {
 struct nb *p0,*p1,*p2;
 p1=head;
 P0=(struct nb *)malloc(LEN);
 scanf("%d,%f",&p0->xh,&p0->cj);
 if(head==NULL)
 {
 head=p0;
 p0->next=NULL;
 goto END;
 }
 while(p0->xh>p1->xh&&p1->next!=NULL)
 {
 p2=p1;
 p1=p1->next;
 }
 if(p0->xh<=p1->xh)
 {
 if(p1==head)
 {
 head=p0;
 p0->next=p1;
 }
 else
 {
 p2->next=p0;
 p0->next=p1;
 }
 }
 else
 {
 p1->next=p0;
 p0->next=NULL;
 }
 END:
 return head;
 }
 
 
 
 void main()
 {
 long a;
 struct nb *str,*zh,*zj;
 str=p();
 sc(str);
 scanf("%d",&a);
 zh=del(str,a);
 sc(zh);
 zj=xd(zh);
 sc(zj);
 
 
 }
 
 | 
 |