栈的基本算法
来源:互联网 发布:qq号码淘宝 编辑:程序博客网 时间:2024/06/12 01:03
#include<stdio.h>#include<malloc.h>
#define Yes 1typedef struct node{ char data; struct node *next;}Snode;void InitStack(Snode *L1){ L1=NULL;} push(Snode *top, char x) { Snode *S; S = (Snode *)malloc(sizeof(Snode)); if (!S) { printf("内存空间不足无法插入! /n"); return 0; } S->data = x; S->next=top; /*新结点链入栈顶*/ top = S; /*新结点成为新的栈顶*/ return 1;}char pop(Snode *top, char e){ Snode * p; if (top!=NULL) { e = top->data; /*原栈顶结点元素赋予e*/ } p=top; /*被删结点赋予P*/ top=top->next; /*设置新栈顶*/ free(p); /*释放原栈顶结点内存空间*/ return e;} StackEmpty(Snode *L){ if(L) return 0; else return 1;}char compare(){Snode *L1;
char ch1,ch2,e2,e1;InitStack(L1);
while((ch1=getchar())!='@'||(ch1=getchar())!='&') push(L1,ch1);while((ch2=getchar())=='&') pop(L1,ch2);while(!StackEmpty(L1)){ e1=pop(L1,ch1); e2= pop(L1,ch2); if(e1==e2) continue; else { printf("No/n");break; }}return Yes;}
main(){ compare(); printf("/n");}
- 栈的基本算法
- 栈的基本算法
- 关于数据结构中的栈的基本算法
- js的栈和队列基本算法
- 顺序栈各种基本运算的算法
- 顺序栈的定义和基本算法
- 基本的排序算法
- 树的基本算法
- 基本的排序算法
- Mapbar的基本算法
- 图的基本算法
- 基本的排序算法
- 基本的排序算法
- 二叉排序树的基本算法
- 图的基本算法
- 基本的排序算法
- 几个基本的算法
- 排列的基本算法
- 图象一些算法
- 基数排序
- 千一网络发布 QuickAjax
- 迷灯的算法
- 暂停Action,返回客户端,问用户是否继续Action下面的操作
- 栈的基本算法
- 《QuickTest Professional Tutorial》读书笔记(10)
- fedora 9中文输入法
- 一道竞赛题
- jQuery DOM操作方法的简单归纳
- Wisdom of Kong Fu Panda
- Reflection in Actionscript 3.0/Flex 2
- 让你的创业失败的18个昏招(zt)
- 在Linux下用wine安装QQ