알고리즘/문제풀이

2566- 최댓값(백준)

WhNi 2024. 5. 27. 19:44

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

 

 

max 가 0일 때는 arr[i][j] > max 가 성립이 안된다고 한다. 

#include <iostream>
#include <vector>

using namespace std;

int main()
{
	
	int arr[9][9];
	int max = -1;

	pair<int, int> position = { 0,0 };	

	for (int i = 0; i < 9; i++)
	{
		for (int j = 0; j < 9; j++)
		{
			cin >> arr[i][j];

			if (arr[i][j] > max)
			{
				max = arr[i][j];
				position = { i + 1,j + 1 };
			}
		}
	}

	cout << max << "\n";
	cout << position.first << " " << position.second << "\n";

	return 0;

};