詳細影片?
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class VectorQueueToQueue {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Queue<Integer> queue = new ArrayDeque<>();
int n;
while (scanner.hasNextInt()) {
n = scanner.nextInt();
int i = 0;
while (i < n) {
if (!scanner.hasNextInt()) break;
int input = scanner.nextInt();
switch (input) {
case 1:
if (!scanner.hasNextInt()) break;
int x = scanner.nextInt();
queue.offer(x);
break;
case 2:
if (queue.isEmpty()) {
System.out.println(-1);
} else {
System.out.println(queue.peek());
}
break;
case 3:
if (!queue.isEmpty()) {
queue.poll();
}
break;
}
i++;
}
}
scanner.close();
}
}