📄 pop.c
字号:
#include<stdio.h>
struct node
{ int data;
struct node * next;
};
void pushs(struct node **top,int x)
{struct node *p;
p=(struct node *)malloc(4);
p->data=x;
p->next=(*top);
(*top)=p;
}
int pops(struct node **top)
{struct node *p;
int x;
if (*top==NULL)
{printf("The stack is underflow");
return(NULL);
}
else x=(*top)->data;
p=(*top);
(*top)=(*top)->next;
free(p);
return(x);
}
main()
{ int i,x;
struct node * h;
printf("please input an int number:\n");
scanf("%d",&i);
while(i!=-1)
{ pushs(&h,i);
printf("please input again:\n");
scanf("%d",&i);
}
x=pops(&h);
printf("%d",x);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -