알고리즘/BaekJoon 단계별로 풀어보기

[2차원 배열] 2566번 - 최댓값 (c++)

jylee3 2024. 11. 3. 20:02

https://www.acmicpc.net/problem/2566

소스 코드 (c++)

#include <iostream>
using namespace std;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int arr[9][9];
	int pos[2] = {0,}, max = 0;
	for (int i = 0; i < 9; i++) {
		for (int j = 0; j < 9; j++) {
			cin >> arr[i][j];
			if (max < arr[i][j]) {
				max = arr[i][j];
				pos[0] = i;
				pos[1] = j;
			}
		}
	}
	cout << max << endl;
	cout << pos[0] + 1 << " " << pos[1] + 1;
}