现有算法如下,说明算法功能,并求给定输入1、2, 3、4、5、6、7、8、9、0时的输出(7分)
#include <stdio.h> #include <stdlib.h> typedef struct Node { int data; struct Node next; }Node,*list; void unknown() { Node *p,*H,*q,*r; int a; H=NULL; scanf("%d",&a); while (a>0) { p=( Node* )malloc(sizeof(Node) p-> data=a; p-> next=H; H=p; scanf("%d" ,&a); } q=p-> -next; while (q!=NULL) { r=q-> next; if(r!=NULL) { q-> next =r-> next; r-> next q; p-> nexter, p=q; q=p-> >next;} else q=NULL; } p=H; while (p!=NULL) { printf("%d ",p->data); p=p-> next;, } }