请求高人解决C语言中一题程序填空题!

来源:百度知道 编辑:UC知道 时间:2024/09/24 04:36:47
给定程序中,函数fun的功能是:计算出带有头结点的单向链表中各结点数据域之和作为函数值返回。
请再程序的下划处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:不得增行或删行,也不得更改程序的结构。

------------程序由此开始---------------

#include <stdio.h>
#include <stdlib.h>
#define N 8
typedef struct list
{ int data;
struct list *next;
} SLIST;
SLIST *creatlist(int *);
void outlist(SLIST *);
int fun( SLIST *h)
{ SLIST *p; int s=0;
p=h->next;
while(p)
{
/**********found**********/
s+= p->___1___;
/**********found**********/
p=p->___2___;
}
return s;
}
main()
{ SLIST *head;
int a[N]={12,87,45,32,91,16,20,48};
head=creatlist(a); outlist(head);
/**********found**********/
printf("\nsum=%d\n", fun(___3___));
}

SLIST *creatlist(int a[])
{ SLIST *h,*p,*q; int i;
h=p=(SLIST *)ma

1:data
2: next
3: head

1 data 2 next 3 可能是a吧 就是将数组a[N]里面的值用链表的形式分别相加求出来,返回到原main函数输出,你好好看看链表那部分