baidu_36153649 2016-09-16 10:48 采纳率: 0%
浏览 938

c语言二级方面的问题,希望大神们解答一下

#include
#include
#define N 8
typedef struct list
{ int data;
struct list next;
} SLIST;
SLIST *creatlist(int *a);
void outlist(SLIST *);
void fun( SLIST *h, int *n)
{ SLIST *p;
/
*********found**********/
1=0;
p=h->next;
while(p)
{ (*n)++;
/**********found**********/
p=p->2;
}
}
main()
{ SLIST head;
int a[N]={12,87,45,32,91,16,20,48}, num;
head=creatlist(a); outlist(head);
/
*********found**********/
fun(head, &num);
printf("\nnumber=%d\n",num);
}
SLIST *creatlist(int a[])
{ SLIST *h,*p,*q; int i;
h=p=(SLIST *)malloc(sizeof(SLIST));
for(i=0; 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");
}
}

  • 写回答

2条回答 默认 最新

  • threenewbee 2016-09-16 15:43
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器