// seqStack.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<stdio.h>
#include<iostream>
#define maxsize 100
typedef struct satck{
int data[maxsize];
int top;
}stack;
//初始化
void initStack(stack &s){
s.top=NULL;
}
//进栈
void pushStack(stack &s){
printf("请输入进栈的值:\n");
int a=0;
for(int i=0;i<5;i++){
scanf_s("%d",&a);
s.data[++s.top]=a;
}
}
//出栈
void popStack(stack &s){
printf("栈中元素为:\n");
while(s.top!=NULL){
printf("%d \n",s.data[s.top--]);
}
}
void _tmain(int argc, _TCHAR* argv[])
{
stack s;
initStack(s);
pushStack(s);
popStack(s);
system("PAUSE");
}