본문 바로가기
백준 알고리즘

[백준][C++] 2566번 : 최댓값

by 탱글한푸딩 2024. 6. 17.
반응형

문제

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

 


코드

#include <iostream>
using namespace std;

#define SIZE 9

int main()
{
	int arr[SIZE][SIZE];

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

	int max = -1;
	int _i = 0, _j = 0;
	for (int i = 0; i < SIZE; i++)
	{
		for (int j = 0; j < SIZE; j++)
		{
			if (arr[i][j] > max)
			{
				max = arr[i][j];
				_i = i + 1;
				_j = j + 1;
			}
		}
	}

	cout << max << '\n' << _i << ' ' << _j << '\n';

	return 0;
}
반응형