F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

View Compilation Error

0_0_39749310_1397\Main.java:1: 错误: 解析时已到达文件结尾
import java.util.Scanner;import java.util.LinkedList;import java.util.Queue;import java.util.Stack;public class main {    public static void main(String[] args) {        Scanner scanner = new Scanner(System.in);        int numTestCases = scanner.nextInt();        scanner.nextLine(); // 消耗换行符        for (int i = 0; i < numTestCases; i++) {            // 读取命令数量和操作类型(FIFO 或 FILO)            String[] input = scanner.nextLine().split(" ");            int numCommands = Integer.parseInt(input[0]);            String operationType = input[1];            Queue<Integer> fifoQueue = new LinkedList<>();            Stack<Integer> filoStack = new Stack<>();            for (int j = 0; j < numCommands; j++) {                input = scanner.nextLine().split(" ");                String command = input[0];                if (command.equals("IN")) {                    int number = Integer.parseInt(input[1]);                    if (operationType.equals("FIFO"))fifoQueue.offer(number);                    } else {                        filoStack.push(number);                    }                } else if (command.equals("OUT")) {                    if (operationType.equals("FIFO")) {                        if (!fifoQueue.isEmpty()) {                            System.out.println(fifoQueue.poll());                        } else {                            System.out.println("None");                        }                    } else {                        if (!filoStack.isEmpty()) {                            System.out.println(filoStack.pop());                        } else {                            System.out.println("None");
                                                                                                                                                                                                                                                                                           ^
1 个错误


Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-26 19:05:35, Gzip enabled