题解 | 【模板】队列操作
【模板】队列操作
https://www.nowcoder.com/practice/1137c8f6ffac4d5d94cc1b0cb08723f9
import java.util.*;
public class Main{
public static void main(String[] args){
Queue<Integer> queue = new LinkedList<>();
Scanner in = new Scanner(System.in);
int n = in.nextInt();
while(n-->0){
int i = in.nextInt();
switch(i){
case 1:
queue.offer(in.nextInt());
break;
case 2:
if(queue.size()!=0){
queue.poll();
break;
}
System.out.println("ERR_CANNOT_POP");
break;
case 3:
if(!queue.isEmpty()){
System.out.println(queue.peek());
break;
}
System.out.println("ERR_CANNOT_QUERY");
break;
case 4:
System.out.println(queue.size());
break;
}
}
}
}

