문제 링크입니다: https://www.acmicpc.net/problem/6437
6437번: Golf
Whoever wants to learn the game of golf has to cope with several oddities first (as with every other game that originates from Great Britain). One of them is the way to count the number of strokes a player needed to put his golf ball in a hole. There is a
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(void) | |
{ | |
int holeNum = 1; | |
while (1) | |
{ | |
int p, s; | |
cin >> p >> s; | |
if (p == 0 && s == 0) | |
{ | |
break; | |
} | |
printf("Hole #%d\n", holeNum++); | |
if (s == 1) | |
{ | |
cout << "Hole-in-one.\n\n"; | |
continue; | |
} | |
switch (s - p) | |
{ | |
case -2: | |
cout << "Eagle.\n\n"; | |
break; | |
case -1: | |
cout << "Birdie.\n\n"; | |
break; | |
case 0: | |
cout << "Par.\n\n"; | |
break; | |
case 1: | |
cout << "Bogey.\n\n"; | |
break; | |
default: | |
if (s - p < -2) | |
{ | |
cout << "Double eagle.\n\n"; | |
} | |
else | |
{ | |
cout << "Double Bogey.\n\n"; | |
} | |
} | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 6491번 Perfection (0) | 2021.06.03 |
---|---|
백준 3602번 iChess (0) | 2021.06.03 |
백준 6378번 디지털 루트 (0) | 2021.06.01 |
BOJ 6322번 직각 삼각형의 두 변 (0) | 2021.05.31 |
백준 6249번 TV Reports (0) | 2021.05.30 |