9.9用友第二题输入处理


本地测试时用 ctrl+d 结束输入,不用管输入什么时候结束。
  Scanner scanner = new Scanner(System.in);
        List<String> list = new ArrayList<>();
        while (scanner.hasNext()) {
            list.add(scanner.nextLine());
        }

        int m = list.size();
        String[] str1 = list.get(0).split(",");
        int n = str1.length;

        int[][] matrix = new int[m][n];

        for (int i = 0; i < m; i++) {
            String[] strs = list.get(i).split(",");
            for (int j = 0; j < n; j++) {
                matrix[i][j] = Integer.valueOf(strs[j]);
            }
        }



#用友##用友校招#
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务