algorithm

더블릿|dovelet - 3번째 계단 - 가장 부지런한 농부/sb

블루건 2016. 8. 21. 23:19

문제


프로그램 명: sb
제한시간: 1 초

딸기 농가 경제가 좋아져서 , 가장 부지런한 농부 한 명에게 보너스를 지급하기로 했습니다.

농부 7 명 , 각 농부별로 수확한 딸기 바구니의 수를 입력 받아서 가장 부지런한 농부 번호를 출력하는 프로그램을 작성하세요.

입력

7 명의 농부가 수확한 딸기 바구니 수가 입력으로 주어진다. 각 수는 100 이하의 자연수이고 같은 수는 입력으로 주어지지 않는다.

입력되는 순서대로 1 번농부 , 2 번 , 3 번 ...

출력

가장 부지런한 농부 번호를 출력한다.

입출력 예

입력

6 2 9 8 1 4 7

출력

3

풀이


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
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main()
{
    int n1, n2, n3, n4, n5, n6, n7;
    cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6 >> n7;
    int maxNumber = max(n1, max(n2, max(n3, max(n4, max(n5, max(n6, n7))))));
    if (maxNumber == n1)
        cout << 1;
    else if (maxNumber == n2)
        cout << 2;
    else if (maxNumber == n3)
        cout << 3;
    else if (maxNumber == n4)
        cout << 4;
    else if (maxNumber == n5)
        cout << 5;
    else if (maxNumber == n6)
        cout << 6;
    else if (maxNumber == n7)
        cout << 7;
    
    return 0;
}
cs