填空题 C语言
题号 #152977

阅读下列程序,则程序实现的功能是 【20】 。 
#include "stdio.h" 
struct node 
{ char data; 
struct node *next; } *head;  
fun(struct node *q) 
{ if(head == NULL) 
{q->next=NULL; 
head=q;} 
else 
{ q->next=head; 
head=q;}} 
main() 
{char ch; 
struct node *p; 
head = NULL; 
while((ch=getchar())!=′\n′) 
{p=(struct node *)malloc(sizeof(struct node)); 
p->data=ch; 
fun(p); } 
p=head; 
while(p!=NULL) 
{printf("%c",p->data); 
p=p->next; }}

进入在线模考

参考答案

暂无

答案解析

从键盘输入一行字符串,调用函数建立反序的链表,然后输出整个链表

你可能感兴趣的试题

A.有且只有1 
B.1或多于1 
C.0或1 
D.至少2
A.e3,e1,e4,e2 
B.e4,e3,e2,e1 
C.e3,e4,e1,e2 
D.任意顺序
找试题 · 找答案 · 找资料 在线模考