才学链栈的进入与出栈时始终显示0怎么会事?
程序代码:#include <stdio.h>
#include <stdlib.h>
struct node{
float Data;
struct node *Next;
};
struct node * InitStack(){
struct node *top;
top = (struct node *)malloc(sizeof(struct node));
top->Next=0;
return top;
}
void Push(struct node *top, float x){
struct node *p;
p=(struct node *)malloc(sizeof(struct node));
p->Next = top->Next;
p->Data=x;
top->Next=p;
}
float Pop(struct node *top){
if(top->Next==0){
printf("栈为空\n");
return 0;
}
struct node *p;
p =top->Next;
float x= p->Data;
top->Next = p->Next;
free(p);
return x;
}
int main(void){
struct node *top;
top = InitStack();
for(int i = 0; i<11;i++){
Push(top,i*1.0);
}
printf("%d\n",Pop(top));
printf("%d\n",Pop(top));
printf("%d\n",Pop(top));
return 0;
}运行结果为0







