📅  最后修改于: 2022-03-11 14:44:51.446000             🧑  作者: Mango
#include
#include
#include
main() {
struct node {
int data;
struct node *next;
}*pNew,*dltPtr;
struct stack_ptr {
int count;
struct node *top;
}*stack;
int i;
scanf("%d",&i);
pNew = new node;
pNew->data = i;
pNew->next = NULL;
stack = new stack_ptr;
stack->count = 1;
stack->top = pNew;
scanf("%d",&i);
while (i != 0){
pNew = new node;
pNew->data = i;
pNew->next = stack->top;
stack->count++;
stack->top = pNew;
scanf("%d",&i);
}
dltPtr = stack->top;
while (dltPtr != NULL) {
printf("% d",dltPtr->data);
dltPtr = dltPtr->next;
}
}