热门

最新

红包

立Flag

投票

同城

我的

发布
m0_58976888
m0_58976888
4 年前
truem0_58976888

#include<stdio.h>
#include<string.h>
#include<malloc.h>
#include<stdlib.h>
struct node
{
int data;
struct node *next;
};
struct stack
{
struct node *front;
struct node *rear;
};
int intque(stack *s)
{
s=(stack*)malloc(sizeof(stack));
s->front=NULL;
s->rear=NULL;
struct node *p=(node *)malloc(sizeof(node));
p->next=NULL;p->data=56;
s->front=p;
s->rear=p;
printf("%d\t",s->rear->data);
}
stack* insert(stack *s,int e)
{
struct node *p=(node *)malloc(sizeof(node));
p->data=e;
p->next=NULL;
s=(stack*)malloc(sizeof(stack));
if(s!=NULL)
{
s->rear->next=p;
s->rear=p;
printf("%d\t",s->rear->data);
}
return s;
}
int out(stack *s)
{
struct node *p=(node *)malloc(sizeof(node));
if(s->front==s->rear)
{
printf("error");
s->front->data=NULL;
}
else
p=s->front->next;
s->front->next=p->next;
}
int main()
{
struct stack *s=NULL;
intque(s);
insert(s,3);
insert(s,5);
}

CSDN App 扫码分享
分享
1
2
打赏
  • 复制链接
  • 举报
下一条:
《暗里刷题》卷出天际致敬正在刷题的你,曾经的 Acmer,永远的荣耀,退役后仍然可以光芒万丈!加入万人千题,参加每日打卡和结对编程排位赛,履行三年之约,实现十年磨一剑!
立即登录