大佬,麻烦帮我看下第一题代码,本地能过,但是 copy 过去死活 0%,不知道是哪里的问题。。。 import java.util.*; public class Main { Queue<Integer> help = new LinkedList<Integer>(); public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); Main test = new Main(); for(int i = 0; i < n; i++) { int k = in.nextInt(); for(int j = 0; j < k; j++) { String aStrings = in.next(); if(aStrings.equals("PUSH")) { test.help.add(in.nextInt()); } else if(aStrings.equals("TOP")) { if(test.help.isEmpty()) System.out.println(-1); else { System.out.println(test.help.peek()); } } else if(aStrings.equals("POP")) { if(test.help.isEmpty()) System.out.println(-1); else { System.out.println(test.help.poll()); } } else if(aStrings.equals("SIZE")) { System.out.println(test.help.size()); } else if(aStrings.equals("CLEAR")) { test.help.clear(); } } test.help.clear(); } } }
点赞 8

相关推荐

牛客网
牛客企业服务