Notice
Recent Posts
Recent Comments
Link
250x250
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

피너클의 it공부방

백준 2566 최댓값 (c++) : 피너클 본문

백준

백준 2566 최댓값 (c++) : 피너클

피너클 2022. 7. 2. 13:23
728x90
반응형

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

 

2566번: 최댓값

첫째 줄에 최댓값을 출력하고, 둘째 줄에 최댓값이 위치한 행 번호와 열 번호를 빈칸을 사이에 두고 차례로 출력한다. 최댓값이 두 개 이상인 경우 그 중 한 곳의 위치를 출력한다.

www.acmicpc.net

간단한 구현문제다.

#include <iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int a, n, m, sum = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			cin >> a;
			if (a >= sum) {
				sum = a;
				n = i;
				m = j;
			}
		}
	}
	cout << sum << endl << n << ' ' << m << endl;
}

전체코드다.

728x90
반응형
Comments