下列程序段实现的功能是

int main ()
{
char x;
node*head,*s;
int n=0;
head=NULL;
x=getchar ();
1221053
while(x!='#”)
{ s=(node *)malloc(sizeof(node));
s->data=x; s->next=head; head=s;
n++;
x=getchar();}
return 0;}

img

用头插法,将输入的字符添加到链表上,遇到#的时候停止输入