본문 바로가기

Algorithm

(C++) - 백준(BOJ) 17009번 : Winning Score

반응형

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

 

17009번: Winning Score

The output will be a single character. If the Apples scored more points than the Bananas, output 'A'. If the Bananas scored more points than the Apples, output 'B'. Otherwise, output 'T', to indicate a tie.

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;
int main() {
    int n;
    int a =0 , b = 0;
    for (int i = 3; i > 0; i--)
    {
        cin >> n;
        a += n * i;
    }
    for (int i = 3; i > 0; i--)
    {
        cin >> n;
        b += n * i;
    }
    if (a > b)
        cout << 'A' << '\n';
    else if (a < b)
        cout << 'B' << '\n';
    else
        cout << 'T' << '\n';
}
cs