题目内容:
阅读下列程序,则程序实现的功能是【20】。
#include"stdio.h"
structnode
{chardata;
structnode*next;}*head;
fun(structnode*q)
{if(head==NULL)
{q->next=NULL;
head=q;}
else
{q->next=head;
head=q;}}
main()
{charch;
structnode*p;
head=NULL;
while((ch=getchar())!=′\n′)
{p=(structnode*)malloc(sizeof(structnode));
p->data=ch;
fun(p);}
p=head;
while(p!=NULL)
{printf("%c",p->data);
p=p->next;}}
参考答案:
答案解析: