C 谁帮我看下这个C程序错在哪!!

来源:百度知道 编辑:UC知道 时间:2024/06/08 03:09:01
#include<stdio.h>
#include<stdlib.h>
typedef struct student
{
int num;
float score;
struct student *next;
}kk;

kk a[3];
kk b[3];

void fun1(kk* head1 ,kk *head2)
{
int i;
head1=&a[0];
head2=&b[0];
a[0].num=10011;a[0].score=97;
a[1].num=10013;a[1].score=94;
a[2].num=10015;a[2].score=90;
b[0].num=10012;b[0].score=97;
b[1].num=10014;b[1].score=93;
b[2].num=10016;b[2].score=92;

for(i=0;i<2;i++)
{
a[i].next=&a[i+1];
b[i].next=&b[i+1];
}
a[i].next=b[i].next=NULL;
}

void fun2(kk *head)
{
kk *p;
p=head;
while(p!=NULL)
{
printf("%d,%.2f\n",p->num,p->score);
p=p->next;
}
}

void main()
{
kk *head1,*head2;
fun1(head1 ,head2);
fun2(head1);
fun2(head2);
}

#include<stdio.h>
#include<stdlib.h>
typedef struct student
{
int num;
float score;
struct student *next;
}kk;

kk a[3];
kk b[3];

void fun1(kk **head1 ,kk **head2)/*.....这里要这样写*/
{
int i;
*head1=&a[0];/*.........这里要这样写*/
*head2=&b[0];/*.........这里要这样写*/
a[0].num=10011;a[0].score=97;
a[1].num=10013;a[1].score=94;
a[2].num=10015;a[2].score=90;
b[0].num=10012;b[0].score=97;
b[1].num=10014;b[1].score=93;
b[2].num=10016;b[2].score=92;

for(i=0;i<2;i++)
{
a[i].next=&a[i+1];
b[i].next=&b[i+1];
}
a[i].next=b[i].next=NULL;
}

void fun2(kk *head)
{
kk *p;
p=head;
while(p!=NULL)
{
printf("%d,%.2f\n",p->num,p->score);
p=p->next;
}
}

void main()
{
kk *head1,*head2;
fun1(&head1 ,&head2);/*.........这里要这样写*/
fun2(head1);
fu