首页 > 试题广场 >

矩阵元素定位

[编程题]矩阵元素定位
  • 热度指数:18437 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
KiKi得到了一个nm列的矩阵,现在他想知道第x行第y列的值是多少,请你帮助他完成这个任务。

数据范围: ,矩阵中的值满足

输入描述:

第一行包含两个数n和m,表示这个矩阵包含n行m列。从2到n+1行,每行输入m个整数(范围-231~231-1),用空格分隔,共输入n*m个数,表示矩阵中的元素。接下来一行输入x和y,用空格分隔,表示KiKi想得到的元素的位置。(1≤x≤n≤10,1≤y≤m≤10)



输出描述:
一行,输出一个整数值,为KiKi想知道的值。
示例1

输入

2 3
1 2 3
4 5 6
1 2 

输出

2
n,m =  list(map(int,input().split()))
new = []
for i in range(n):
    arr1 = input().split()
    new.append(arr1)

n1,m1 = list(map(int,input().split()))
print(new[n1-1][m1-1])


发表于 2024-09-28 00:54:38 回复(0)
多维列表
n,m=map(int,input().split())
a = []
for i in range(n):
    b = list(map(int,input().split()))
    a.append(b)
x,y=map(int,input().split())
print(a[x-1][y-1])


编辑于 2024-02-07 17:02:35 回复(0)
n, m = map(int, input().split())
a = []
for i in range(n):
        a.append(input().split())
x, y = map(int, input().split())
print(a[x-1][y-1])

发表于 2021-08-26 10:38:11 回复(0)