Stack 为什么即使是小的输入也会出现SIGTSTP错误?

Stack 为什么即使是小的输入也会出现SIGTSTP错误?,stack,Stack,我试图在spoj上解决这个问题。我已经根据自己的知识编写了代码。但是,我不知道为什么会出现这个错误。请帮我找出代码中的错误。提前感谢 #include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; while(n!=0) { int i,arr[n]; for(i=0;i<n;i++) cin>

我试图在spoj上解决这个问题。我已经根据自己的知识编写了代码。但是,我不知道为什么会出现这个错误。请帮我找出代码中的错误。提前感谢

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    while(n!=0)
    {
        int i,arr[n];
        for(i=0;i<n;i++)
            cin>>arr[i];
        int temp=1;
        stack<int>s;
        i=0;
        while(arr[i]!=temp and i<n)
        {
            s.push(arr[i]);
            i++;
        }
        temp++;
        bool flag=false;
        while(true)
        {
            if(temp==n+1)
            {
                flag=true;
                break;
            }
            else if(!s.empty())
            {
                if(s.top()==temp)
                {
                    s.pop();
                    temp++;
                }
            }
            else if(i!=n-1)
            {
                if(arr[i+1]==temp)
                {
                    i++;
                    temp++;
                }
                else
                {
                    int j=i+1;
                    while(arr[j]!=temp and j<n)
                    {
                        s.push(arr[j]);
                        j++;
                    }
                    i=j-1;
                }
            }
            else if(!s.empty())
            {
                if((s.top()!=temp) and ((i!=n-1) and (arr[i+1]!=temp)))
                    break;
            }
        }
        if(flag)
            cout<<"yes";
        else
            cout<<"no";
        if(n)
            cout<<"\n";
        cin>>n;
    }
    return 0;
#包括
使用名称空间std;
int main()
{
int n;
cin>>n;
而(n!=0)
{
int i,arr[n];
对于(i=0;i>arr[i];
内部温度=1;
堆叠;
i=0;

while(arr[i]!=temp和i在
while(true)
当:

  • temp!=n+1
  • 并且
    s.empty()
    为false
  • s.top()!=temp

可能还有其他错误…

最好描述一下您的代码的功能。我启动了,但它没有做任何事情,而且我没有收到任何错误