该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
#include
#include
using namespace std;
typedef struct Stack
{
int *bottom;
int *top;
}Stack;
int Init_stack(Stack *s)
{
s->bottom=(int*)malloc(sizeof(int));
s->bottom=s->top;
return 0;
}
int pop(Stack *s,int *e)
{
s->top--;
*e=*s->top;
return 0;
}
int push(Stack *s,int e)
{
*s->top=e;
s->top++;
return 0;
}
int main()
{
int n,i;
int c=1;
int a[100];
int m;
int *p;
Stack *s;
Init_stack(s);
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
for(i=1;i<=n;i++)
{
while(c<=a[i])
{
push(s,c);
c++;
}
pop(s,p);
if(*p!=a[i])
{
printf("NO");
return 0;
}
}
printf("YES");
return 0 ;
}
请问这段代码哪里出问题了吗。。。我找了好久了,找不出