sdut oj 2556 传说中的数据结构

sdut oj 2556 传说中的数据结构#include <stdio.h>
#include <string.h>


int main()
{
    char s[10];
    int a[10000];
    int T, i, j;
    while(~scanf("%d", &T))
    {
        j = 0;
        for(i = 1; i <= T; i++)
        {
            scanf("%s", s);
            if(strcmp(s, "push") == 0)
            {
                scanf("%d", &a[j]);
                j++;
            }
            else if(strcmp(s, "pop") == 0)
            {
                if(j == 0)
                    printf("error\n");
                else
                    j--;
            }
            else if(strcmp(s, "top") == 0)
            {
                if(j >= 1)
                    printf("%d\n", a[j - 1]);
                else
                    printf("empty\n");
            }
        }
        printf("\n");
    }
    return 0;
}