#include <stdio.h>
#include <stdlib.h>
#define N 10000
typedef int datatype;
typedef struct link stack;
struct link {
int top;
int data[N];
};
void push(stack *st,datatype x);
void pop(stack *st);
int main() {
int i,j,k,n;
int a[N];
stack *st;
scanf("%d",&n);
for(i=1; i<=n; i++) {
scanf("%d",&a[i]);
}
st=(stack*)malloc(sizeof(stack));
st->top=0;
i=1,j=i+1;
while(i<N) {
if(a[i]>a[j]) {
push(st,a[j]);
i++;
j++;
}else{
st->data[1]=a[j];
pop(st);
}
}
return 0;
}
void push(stack *st,datatype x) {
if(st->top==N) {
printf("\n栈满");
exit(1);
}
st->data[st->top]=x;
st->top++;
}
void pop(stack *st) {
if(st->top==0) {
printf("\n栈空");
exit(1);
}
st->top--;
}
刚学数据结构没思路