1044 顺序栈基本操作的实现

来源:互联网 发布:php前端开发 编辑:程序博客网 时间:2024/05/16 13:06

地址:http://acm.swust.edu.cn/problem/1044/

#include<stdio.h>

int main()
{
int N;
while(scanf("%d",&N)!=EOF)
{
int arr[1000];
int top,i;
for(top=0;top<N;top++)
{
scanf("%d",&arr[top]);
}
top-=1;
int k;
scanf("%d",&k);
for(i=0;i<k;i++)
{
top--;
}
if(top<0)
printf("-1");
else
printf("%d",arr[top]);
}
return 0;
}
0 0