코딩로그
[백준/BOJ/C++] 17009번 Winning Score 본문
[문제]
You record all of the scoring activity at a basketball game. Points are scored by a 3-point shot, a 2-point field goal, or a 1-point free throw.
You know the number of each of these types of scoring for the two teams: the Apples and the Bananas. Your job is to determine which team won, or if the game ended in a tie.
[입력]
The first three lines of input describe the scoring of the Apples, and the next three lines of input describe the scoring of the Bananas. For each team, the first line contains the number of successful 3-point shots, the second line contains the number of successful 2-point field goals, and the third line contains the number of successful 1-point free throws. Each number will be an integer between 0 and 100, inclusive.
[출력]
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.
[Source Code]
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int applescore = 0, bananascore = 0;
for(int i = 3; i >= 1; i--){
int input;
cin >> input;
applescore += input * i;
}
for(int i = 3; i >= 1; i--){
int input;
cin >> input;
bananascore += input * i;
}
if(applescore > bananascore)
cout << 'A';
else if(applescore < bananascore)
cout << 'B';
else
cout << 'T';
}
[결과 화면]
'YJ > C++' 카테고리의 다른 글
[백준/BOJ/C++] 23234번 The World Responds (0) | 2021.10.22 |
---|---|
[백준/BOJ/C++] 19602번 Dog Treats (0) | 2021.10.22 |
[백준/BOJ/C++] 5086번 배수와 약수 (0) | 2021.10.22 |
[백준/BOJ/C++] 14920번 3n+1 수열 (0) | 2021.10.22 |
[백준/BOJ/C++] 10569번 다면체 (0) | 2021.10.21 |