拼多多笔试题第一题输入错误是为什么呀?

携程和拼多多,都是为了acm输入输出痛苦orz。

我的输入输出是这样的,语言是java:
 *     public static void main(String[] args) {
 *         Scanner in = new Scanner(System.in);
 *         while (in.hasNext()) {
 *             //只有可能理论上已经读完了关卡,要到下一个去了,却到了关卡里面……
 *             int n = in.nextInt();
 *             int m = in.nextInt();
 *             int[][] nums = new int[n][3];
 *             for(int i = 0; i < n; i++) {
 * //              给的是字符还是字符串啊
 *                 String s = in.next();
 *                 nums[i][0] = s.charAt(0);
 *                 nums[i][1] = in.nextInt();
 *                 nums[i][2] = nums[i][0] - 'm' == 0? in.nextInt() : 0;
 *             }
 *             System.out.println(solution(nums));
 *         }
 *     }
不知道会不会乱码,放上图片:
全部评论
我这题也就写了输入输出
2 回复 分享
发布于 2023-03-30 17:27 广东
第一行后面后面有个'\n',nextInt不会读\n,需要用nextLine读
点赞 回复 分享
发布于 2023-03-30 17:19 吉林
我都是一行一行读的
点赞 回复 分享
发布于 2023-03-30 17:14 广东

相关推荐

评论
1
2
分享

创作者周榜

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