dalgorithm
달공의 개발기
dalgorithm
전체 방문자
오늘
어제
  • 분류 전체보기 (170)
    • Back-end (0)
    • Java (11)
    • 자료구조 (7)
    • Network (31)
    • Database (9)
    • Baekjoon Online (24)
    • 클라우드 (6)
    • Android (15)
      • Kotlin (14)
    • AI (27)
      • Machine Learning&Deep Learn.. (27)
    • Web (23)
      • Webhacking (17)
      • WebProgramming (6)
    • 기술면접 (1)
      • JAVA&자료구조 (0)
      • Spring (0)
      • 컴퓨터구조&운영체제 (0)
      • 네트워크 (0)
      • 데이터베이스 (0)
    • CTF 스터디 (15)
    • 대외활동 (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 데이터베이스
  • 인공지능
  • 클라우드
  • cs
  • java
  • 포너블
  • 코드리뷰
  • 자바
  • 딥러닝
  • python #백준
  • 자료구조
  • CTF
  • db
  • gcp
  • kotlin
  • Guacamole
  • 침입탐지
  • 네트워크
  • 머신러닝
  • 웹해킹

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
dalgorithm

달공의 개발기

[C] 백준 17009번_Winning Score
Baekjoon Online

[C] 백준 17009번_Winning Score

2021. 1. 2. 23:48
728x90

출처: 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

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.

 


농구게임의 모든 점수를 기록한다.  3포인트 샷, 2포인트 필드골, 1포인트 자유투가 있다.

두 팀으로 나눠져 점수를 정리한다. 예를 들어 팀 이름은 사과, 바나나가 된다. 나는 어느 팀이 이기는지 확인해야한다.

 

첫 입력 세줄은 사과 팀의 점수이고, 다음 세줄은 바나나팀의 점수이다. 각 세줄의 첫줄은 3점, 두 번째 줄은 2점, 마지막 줄은 1점짜리이다. 각 숫자의 합은 0에서 100사이일 것이다. 

 

결과는 단독 값일 것이다. 만약 사과팀이 더 많은 점수를 냈다면, 결과는 'A'일 것이고, 바나나가 이겼다면 'B'일 것이다. 반면 "T"일 경우네는 동점이다.

 

먼저 사과팀의 득점 변수를 a1, a2, a3로 정의해주고, 바나나팀의 득점 변수는 b1,b2,b3로 설정해주었다.

각 점수의 합은 sumA, sumB이고 scanf를 통해 값을 입력해준다.

 

sumA는 (a1*3)+(a2*2)+(a3*1)로 이루어진다. sumB도 마찬가지로 (b1*3)+(b2*2)+(b3*1)이다.

그리고 if-else if로 조건문을 설정해준다.

 

sumA가 sumB보다 클 경우 A를 출력하고, 그 반대일 경우 B, 그리고 동점일 경우에는 T를 출력해주어 마무리를 해주었다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
 
int main(void) {
 
    int a1, a2, a3, b1, b2, b3; //득점 입력
    int sumA, sumB = 0; //총합 초기화
 
    scanf("%d", &a1);
    scanf("%d", &a2);
    scanf("%d", &a3);
    scanf("%d", &b1);
    scanf("%d", &b2);
    scanf("%d", &b3); //
 
    sumA = 3 * a1 + 2 * a2 + a3;
    sumB= 3 * b1 + 2 * b2 + b3;
 
    if (sumA > sumB) printf("A"); //A합이 B합보다 클 경우 A 출력
    else if (sumA < sumB) printf("B"); //반대일 경우 B출력
    else printf("T"); //동점일 경우 T출력
 
    return 0;
}
Colored by Color Scripter
cs

 

 

 

728x90

'Baekjoon Online' 카테고리의 다른 글

[C] 백준 2588번_곱셈  (0) 2021.01.07
[C] 백준 2798번_블랙잭  (0) 2021.01.06
[python] 백준 8958번_OX퀴즈  (0) 2021.01.05
[c] 백준 9713번_Sum of Odd Sequence  (0) 2021.01.04
[C] 백준 10809번_알파벳 찾기  (0) 2021.01.03
    'Baekjoon Online' 카테고리의 다른 글
    • [C] 백준 2798번_블랙잭
    • [python] 백준 8958번_OX퀴즈
    • [c] 백준 9713번_Sum of Odd Sequence
    • [C] 백준 10809번_알파벳 찾기
    dalgorithm
    dalgorithm

    티스토리툴바