题解 | #矩阵元素定位#

矩阵元素定位

http://www.nowcoder.com/practice/b8e6a46992fe4e11b2822b20561b6d94

import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        StringBuilder numStr = new StringBuilder();
//要用nextLine需要先把m后面的换行符读取
        sc.nextLine();
        for(int i = 0; i < n; i++){
            numStr.append(sc.nextLine());
            numStr.append(" ");
        }
        int x = sc.nextInt();
        int y = sc.nextInt();
        String str = new String(numStr);
        String[] nums = str.split(" ");
        System.out.println(nums[(x-1)*m+y-1]);
    }
}
全部评论

相关推荐

2025-12-17 12:08
门头沟学院 产品经理
牛客85811352...:1希音不知道算不算大厂 2完全符合,过得很舒服, 3确实只有杂活 领导找我续签到明年3、4月我要继续吗。主要是边实习边秋招这段时间还是有点累
什么是优秀的实习经历
点赞 评论 收藏
分享
2025-11-07 15:41
暨南大学 C++
用微笑面对困难:我面试时候,就说了句”不愧是徐波的兵“他就破房了说是
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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