提交显示运行错误,怎么回事求助啊,Java新手中的新手
查看原帖
提交显示运行错误,怎么回事求助啊,Java新手中的新手
556438
萌新程序员楼主2021/10/13 21:56
package pac1;
import java.util.Scanner;
import java.util.Stack;
 class Operate {
     public void seek(int[] pushed, int[] poped, int b){
        Stack<Integer> stack=new Stack<Integer>();
            for(int j=0;j<b;j++){
            stack.push(pushed[j]);
        }
            for(int i=0;i<b;i++){
            if(stack.peek()==poped[i]){
                stack.pop();
            }
        }
            if(stack.empty()){
            System.out.println("Yes");
        }
            else{
            System.out.println("No");
        }
     }
}
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a;
        int b;
        //询问次数
        a= sc.nextInt();
        //序列长度
        for(int k=0;k<a;k++) {
            b = sc.nextInt();
            int[] pushed = new int[b];
            int[] poped = new int[b];

            for (int j = 0; j < b; j++) {
                pushed[j] = sc.nextInt();
            }
            for (int i = 0; i < b; i++) {
                poped[i] = sc.nextInt();
            }
            Operate op = new Operate();
            op.seek(pushed, poped, b);
        }
        return;
    }
}

2021/10/13 21:56
加载中...