填空题
以下程序中函数fun的功能是:构成一个如图所示的带头结点的单向链表,在结点的数据域中放入了具有两个字符的字符串。函数disp的功能是显示输出该单链表中所有结点中的字符串。请填空完成函数
disp。
#include
typedef struct node/*链表结点结构*/
{char sub[3];
struct node * next;
}Node;
Node fun(char S) /*建立链表*/
{ ……}
void disp(Node *h)
{Node*P;
P=h->next;
while(【 】)
{printf("%s\n",P->sub);P=【 】; }
}
main()
{Node *hd;
hd=fun();disp(hd);prinff("\n");
}
【参考答案】
p!=NULL,p->next
热门
试题
单项选择题
有以下程序:int f(int b[ ][4]){ int i,j,s=0;for(j=0;j2) i=3-j;s+=b[i][j]; }return s; }main( ){ int a[4][4]={{1,2,3,4},{0,2,4,5},{3,6,9,12},{3,2,1,0}};printf(“%d n”,f(a)); }执行后的输出结果是( )。
A.12
B.11
C.18
D.16