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 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题