热门

最新

红包

立Flag

投票

同城

我的

发布
breeze21
哈哈哈hhhhhh
4 年前
truebreeze21

代码与理论不可分,我总是忽略代码,直到现在我才明白这个道理,很多理论都是拿来用的,怎么用?代码

CSDN App 扫码分享
分享
评论
1
打赏
  • 复制链接
  • 举报
下一条:
#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); }
立即登录