题解 | #矩阵元素定位#

矩阵元素定位

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

相关推荐

06-27 18:45
中山大学 Ruby
25届应届毕业生,来广州2个礼拜了,找不到工作,绝望了,太难过了…
应届想染班味:9爷找不到工作只能说明,太摆了或者太挑了。
点赞 评论 收藏
分享
积极的小学生不要香菜:你才沟通多少,没500不要说难
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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