23-06-28 계륵 일기

E woo·2023년 6월 28일

계륵 일기

목록 보기
5/31
post-thumbnail

최댓값 범위 확인

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

최댓값의 범위가 0 혹은 100 보다 작은 자연수로
max 가 0 일 때의 행과 열도 알아내야 하기 때문에

조건문은 arr[i][j] > max가 아닌 arr[i][j] >= max 가 되어야 한다.

#include <iostream>

using namespace std;

int main()
{

    int arr[9][9];
    int max = 0;

    int row, column;
    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];
                row = i + 1;
                column = j + 1;
            }
        }
    }
    cout << max << "\n";
    cout << row << " " << column;

    return 0;
}
profile
뒘벼

0개의 댓글