본문 바로가기
Algorithm/백준

[Algorithm][C언어] 백준 17009번: Winning Score

by 8희 2022. 9. 26.

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

 

17009번: Winning Score

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

www.acmicpc.net

 

 

농구 경기에서 모든 득점 활동을 기록합니다. 3점슛, 2점 필드골, 1점 자유투로 득점한다.
사과와 바나나라는 두 팀의 각 유형의 득점 횟수를 알고 있다. 
어느 팀이 이겼는지 또는 게임이 동점으로 끝났는지 결정해라.

 

#include <stdio.h>

int main(){
    int arr[5], A = 0, B = 0; //사과 팀 A, 바나나 팀 B
    
    for (int i = 0; i < 6; i++)
        scanf("%d", &arr[i]); //입력 값을 배열로 받기
        
    A = arr[0]*3 + arr[1]*2 + arr[2]; //순서대로 3, 2, 1 곱하기
    B = arr[3]*3 + arr[4]*2 + arr[5]; //순서대로 3, 2, 1 곱하기
    
    if (A == B) //비겼으면
        printf("T"); //T 출력
    else if (A > B) //사과 팀이 이기면
        printf("A"); //A 출력
    else //바나나 팀이 이기면
        printf("B"); //B 출력
        
    return 0; //종료
}