厦门市长福州市长级别:谁帮我解决这个C语言问题啊~~ 后面怎么输出啊

来源:百度文库 编辑:神马品牌网 时间:2024/05/01 13:38:03
#include<stdlib.h>
#include<string.h>
#include NUM 5
#define LEN_A sizeof(struct list_a)
#define LEN_B sizeof(struct list_b)
#define LEN_C sizeof(struct list_c)
struct list_a
{int number_a;
char name_a[20];
struct list_a *next_a;
};
struct list_b
{int number_b;
int score_b;
struct list_b *next_b;
};
struct list_c
{int number_c;
char name_c[20];
int score_c;
struct list_c *next_c;
};
main()
{struct list_a *p1_a,*p2_a,*h_a;
struct list_b *p1_b,*p2_b,*h_b;
struct list_c *p1_c,*p2_c,*h_c;
p2_a=(struct list_a *)malloc(LEN_A);
p1_a=p2_a;
h_a=p2_a;
printf("\n please input the number and name:");
scanf("%d%s",&p2_a->number_a,&p2_a->name_a);
p2_a->next=NULL;
while(i<NUM)
{p2_a=(struct list_a *)malloc(LEN_A);
p2_a->next=NULL;
p1_a->next=p2_a;
p1_a=p2_a;
printf("\n please input the number and name:");
scanf("%d%s",&p2_a->number_a,&p2_a->name_a);
i++;
}

p2_b=(struct list_b *)malloc(LEN_B);
p1_b=p2_b;
h_b=p2_b;
printf("\n please input the number and name:");
scanf("%d%s",&p2_b->number_b,&p2_b->name_b);
p2_b->next=NULL;
while(i<NUM)
{p2_b=(struct list_b *)malloc(LEN_B);
p2_b->next=NULL;
p1_b->next=p2_b;
p1_b=p2_b;
printf("\n please input the number and name:");
scanf("%d%s",&p2_b->number_b,&p2_b->name_b);
i++;
}
p2_c=(struct list_c *)malloc(LEN_c)
p1_c=p2_c;
h_c=p2_c;
p2_a=h_a;
p2_c->number=p2_a->number_a;
strcpy(p2_c->name_c,p2_a->name_a);
p2_b=h_b;
while(p2_b->number_b!=p2_a->number_a)
p2_b=p2_b->next_b;
p2_c->score_c=p2_b->score_b;
p2_c->next_c=NULL;
p2_a=p2_a->next_a;
while(p2_a!=0)
{p2_c=(struct list_c *)malloc(LEN_c)
p1_c=p2_c;
h_c=p2_c;
p2_a=h_a;
p2_c->number_c=p2_a->number_a;
strcpy(p2_c->name_c,p2_a->name_a);
p2_b=h_b;
while(p2_b->number_b!=p2_a->number_a)
p2_b=p2_b->next_b;
p2_c->score_c=p2_b->score_b;
p2_c->next_c=NULL;
p2_a=p2_a->next_a;
}
struct list_c *p;
p=h_c;
if(h_c!=NULL)
printf("head");
do
{printf("->%d %s %d",h_c->number_c,h_c->name_c,h_c->score_c);
p=p->next;
}while(p!=NULL);
}

这么长的程序还不给一点分数