博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj——1363 栈的使用
阅读量:6986 次
发布时间:2019-06-27

本文共 935 字,大约阅读时间需要 3 分钟。

#include 
using namespace std;typedef struct Node{ int info; Node * link;}Node;typedef struct LinkStack{ Node * top;}LinkStack;int push(LinkStack * stack, int x){ Node * p = new Node; p->info = x; p->link = stack->top; stack->top = p; return 1;}int pop(LinkStack * stack){ if (stack->top == NULL){ printf("栈为空!\n"); return -1; } else { Node * p; p = stack->top; stack->top = stack->top->link; int t = p->info; return t; }}int main(){ int train; while(scanf("%d",&train)&&train){ int trains[1001]; while(1){ scanf("%d",&trains[0]); if(trains[0]==0){ printf("\n"); break; } else { for(int x=1;x
top = NULL; int num=0; for(int i=0;i
top!=NULL&&stack->top->info==trains[num]){ pop(stack); num++; } } if (num==train) cout << "Yes" << endl; else cout << "No" << endl; } } }

  

转载于:https://www.cnblogs.com/lvcoding/p/7486501.html

你可能感兴趣的文章
页面瘦身之压缩viewState和保存viewState到服务器
查看>>
POJ 1655 Balancing Act[树的重心/树形dp]
查看>>
[题集]图论
查看>>
android view知识点 总结
查看>>
记一个鼠标略过时候的css动画
查看>>
HTTP协议
查看>>
slave->pxc后GTID不一致
查看>>
WPF 与Surface 2.0 SDK 亲密接触 - 图形缩放篇
查看>>
PhotoShop常用的功能汇总
查看>>
基于移动端Reactive Native轮播组件的应用与开发详解
查看>>
专家的修炼之路 —— 德雷福斯模型 Dreyfus
查看>>
TcpClient和TcpListener 类的使用-编写一个点对点聊天工具(初级入门篇)
查看>>
CSS 圆角
查看>>
C#解压缩文件
查看>>
Golang学习笔记——Slice
查看>>
ERDAS软件应用(三)遥感图像的拼接
查看>>
在面试中如何展示虚拟机和内存调优技能
查看>>
hdu 1534 Schedule Problem (差分约束)
查看>>
HDU1159 Common Subsequence【最长公共子序列】
查看>>
C++ 字符数组函数与string函数
查看>>