#include <stdio.h>
#include <stdlib.h>
struct Stack{
int data;
struct Stack *next;
};
void Push(Stack **stack,int data){
Stack *t = (struct Stack*)malloc(sizeof(struct Stack));
t->data = data;
t->next = *stack;
*stack = t;
}
void pop(Stack *stack){
if(!stack){
printf("栈已空\n");
return;
}
Stack *p = stack;
printf("%d",p->data);
free(p);
stack = stack->next;
}
int main() {
Stack *stack =NULL;
Push(&stack,2);
Push(&stack,4);
pop(stack);pop(stack);
return 0;
}
入栈2和4
弹出为什么是一串数字??