bogyoi's Dev note
[백준/python] 2566번 최댓값: 2차원 행렬에서 최댓값 찾고 해당 위치(행,열) 출력/ max(map(max, arr))
arr=[0]*9 for i in range(9): arr[i]=list(map(int, input().split())) for i in range(9): for j in range(9): if arr[i][j]==max(map(max, arr)): a,b=i+1,j+1 print(max(map(max, arr)), a,b) max(map(max, arr)) 를 통해 2차원 리스트에서 최댓값을 찾게 했다. 인덱스를 구하기위해 2중 for-loop를 돌면서 최댓값을 발견하게 되면 그 자리의 위치(i,j)를 받아 출력하게함. 파이썬에서 인덱스의 위치를 반환해주는 index() 함수가 있는데, 2차원 리스트에서는 위와 같이 for-loop를 사용해 일일히 비교를 하거나, List comprehension를 사..
2023. 10. 24.