问题出在哪里呢?好像是输入6以后有什么没初始化,导致后面的答案错了,如果我第一组就输入6答案就是对的了,有大佬帮忙指出问题吗
#include<stdio.h>
int a[100000],b[100000];
int main()
{
int n,i,t;
while(scanf("%d",&n),n)
{
while(scanf("%d",&a[0]),a[0])
{
int top=1;
for(i=1;i<n;i++)
{
scanf("%d",&a[i]);
}
i=1,t=0;
while(i<=n)
{
b[top]=i;
while(a[t]==b[top]&&t<n)
{
printf("%d ",a[t]);
top--;
t++;
}
top++;
printf("%d\n",top);
i++;
}
if(top==1)
{
printf("Yes\n");
}
else
{
printf("No\n");
}
}
printf("\n");
}
}