题解 | #矩阵元素定位#

矩阵元素定位

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]);
    }
}
全部评论

相关推荐

牛客77743221...:做一段时间,公司出钱送你去缅甸和泰国旅游
点赞 评论 收藏
分享
11-19 18:44
已编辑
成都理工大学 Java
程序员花海:我面试过100+校招生,大厂后端面试不看ACM,竞赛经历含金量低于你有几份大厂实习 这个简历整体来看不错 可以海投
如何写一份好简历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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