码迷,mamicode.com
首页 > 其他好文 > 详细

山理工oj 2556传说中的数据结构

时间:2019-10-13 20:33:42      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:erro   传说   char s   har   eof   ring   int   err   pop   

#include<stdio.h>
#include<string.h>
int main()
{
int n,i,j=0,k,a[1000];
char str1[5]="push",str2[4]="pop",str3[4]="top",str[8];
while(~scanf("%d",&n))
{
j=-1;
memset(a,0,sizeof(a));
for(i=0;i<=n-1;i++)
{
scanf("%s",str);
if(strcmp(str,str1)==0)
{
scanf("%d",&k);
a[++j]=k;
}
else if(strcmp(str,str2)==0)
{
if(j<0) printf("error\n");
else {j-=1;}
}
else if(strcmp(str,str3)==0)
{
if(j<0) printf("empty\n");
else printf("%d\n",a[j]);
}
}
printf("\n");
}
}

山理工oj 2556传说中的数据结构

标签:erro   传说   char s   har   eof   ring   int   err   pop   

原文地址:https://www.cnblogs.com/Cnxz/p/11668026.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!