C语言高手帮我填空#include <stdio.h>#include <stdlib.h>#define N 8typedef struct list{ int data; struct list *next;} SLIST;SLIST *creatlist(int *);void outlist(SLIST *);int fun( SLIST *h){ SLIST *p; int s=0;
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 14:32:41
C语言高手帮我填空#include <stdio.h>#include <stdlib.h>#define N 8typedef struct list{ int data; struct list *next;} SLIST;SLIST *creatlist(int *);void outlist(SLIST *);int fun( SLIST *h){ SLIST *p; int s=0;
C语言高手帮我填空
#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)
{
//
printf("\nsum=%d\n", fun(___3___));
}
SLIST *creatlist(int a[])
{
SLIST *h,*p,*q; int
i;
h=p=(SLIST *)malloc(sizeof(SLIST));
for(i=0; i<N; i++)
{ q=(SLIST
*)malloc(sizeof(SLIST));
q->data=a[i];
p->next=q; p=q;
}
p->next=0;
return h;
}
void outlist(SLIST *h)
{ SLIST *p;
p=h->next;
if
(p==NULL) printf("The list is
NULL!\n");
else
{ printf("\nHead ");
do
{ printf("->%d",
p->data); p=p->next; }
while(p!=NULL);
printf("->End\n");
}
}
C语言高手帮我填空#include <stdio.h>#include <stdlib.h>#define N 8typedef struct list{ int data; struct list *next;} SLIST;SLIST *creatlist(int *);void outlist(SLIST *);int fun( SLIST *h){ SLIST *p; int s=0;
1 . data
2. next
3. head
运行结果: