#include
#include
typedef int elme;
typedef
struct node {
?elme data;
?struct node* next;
}Status;
Status* create()//頭節(jié)點(diǎn)
{
?Status* p = (Status*)malloc(sizeof(Status));
?if (p == NULL)
?{
??? ?exit(0);
?}
?else {
??? ?p->next = NULL;
?}
?return p;
}
Status* createnode(elme data)//做好節(jié)點(diǎn)放入數(shù)據(jù)返回;
{
?Status* p = (Status*)malloc(sizeof(Status));
?if (p == NULL)
?{
??? ?exit(0);
?}
?else {
??? ?p->data = data;
??? ?p->next = NULL;
?}
?return p;
}
void push(Status* p )//頭插法即為棧
{
?Status* s;
?int a=1 ;
?elme b;
?while (a)
?{ ?
??? ?printf("輸入要插入的數(shù)據(jù):");
??? ?scanf_s("%d", &b);
??? ?s = createnode(b);
??? ?s->next = p->next;
??? ?p->next = s;
??? ?printf("是否繼續(xù)輸入1(是)或者0(否)\n");
??? ?scanf_s("%d", &a);
?}
}
void pop(Status*p)//推出
{
?Status* s = p->next;
?while (s)
?{
??? ?printf("%d\n", s->data);
??? ?p->next = s->next;
??? ? s = p->next;
?}
}
int main()
{
?Status* t = create ();
??
?push(t);
?pop(t);
?return 0;
}
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購,新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧