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_39729479_14457\Main.java:1: 错误: 解析时已到达文件结尾
import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class HDU2019 {    public static void main(String[] args) {        Scanner scanner = new Scanner(System.in);        while (true) {            // 读取n和m            int n = scanner.nextInt();            int m = scanner.nextInt();            // 如果n和m都为0,结束输入            if (n == 0 && m == 0) {                break;            }            // 读取已排序的n个数            List<Integer> sortedList = new ArrayList<>();            for (int i = 0; i < n; i++) {                sortedList.add(scanner.nextInt());            }            // 在合适的位置插入m            insertInOrder(sortedList, m);            // 输出插入后的序列            for (int i = 0; i < sortedList.size(); i++) {                System.out.print(sortedList.get(i));                if (i < sortedList.size() - 1) {                    System.out.print(" "); // 空格分隔                }            }            System.out.println(); // 换行        }        scanner.close();    }    private static void insertInOrder(List<Integer> sortedList, int m) {        // 找到插入位置  int i = 0;        while (i < sortedList.size() && sortedList.get(i) < m) {            i++;        }        // 插入m到合适的位置        sortedList.add(i, m);}}
                                                                                                                                                                                                                   ^
0_0_39729479_14457\Main.java:1: 错误: 解析时已到达文件结尾
import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class HDU2019 {    public static void main(String[] args) {        Scanner scanner = new Scanner(System.in);        while (true) {            // 读取n和m            int n = scanner.nextInt();            int m = scanner.nextInt();            // 如果n和m都为0,结束输入            if (n == 0 && m == 0) {                break;            }            // 读取已排序的n个数            List<Integer> sortedList = new ArrayList<>();            for (int i = 0; i < n; i++) {                sortedList.add(scanner.nextInt());            }            // 在合适的位置插入m            insertInOrder(sortedList, m);            // 输出插入后的序列            for (int i = 0; i < sortedList.size(); i++) {                System.out.print(sortedList.get(i));                if (i < sortedList.size() - 1) {                    System.out.print(" "); // 空格分隔                }            }            System.out.println(); // 换行        }        scanner.close();    }    private static void insertInOrder(List<Integer> sortedList, int m) {        // 找到插入位置  int i = 0;        while (i < sortedList.size() && sortedList.get(i) < m) {            i++;        }        // 插入m到合适的位置        sortedList.add(i, m);}}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ^
2 个错误


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-15 08:05:28, Gzip enabled