填空题
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.GEDHFBCA
B.DGEBHFCA
C.ABCDEFGH
D.ACBFEDHG