[백준 6437] Golf (C#, C++) - soo:bak
작성일 :
문제 링크
설명
입력으로 주어지는 정보를 바탕으로 골프의 최종 점수를 출력하는 문제입니다.
Code
[ C# ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
namespace Solution {
class Program {
static void Main(string[] args) {
int holeNumber = 1;
while (true) {
var input = Console.ReadLine()!.Split(' ');
var par = int.Parse(input[0]);
var strokes = int.Parse(input[1]);
if (par == 0) break ;
Console.WriteLine($"Hole #{holeNumber}");
if (strokes == 1) Console.WriteLine("Hole-in-one.\n");
else if (strokes <= par - 3) Console.WriteLine("Double eagle.\n");
else if (strokes == par - 2) Console.WriteLine("Eagle.\n");
else if (strokes == par - 1) Console.WriteLine("Birdie.\n");
else if (strokes == par) Console.WriteLine("Par.\n");
else if (strokes == par + 1) Console.WriteLine("Bogey.\n");
else Console.WriteLine("Double Bogey.\n");
holeNumber++;
}
}
}
}
[ C++ ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int holeNumber = 1;
while (true) {
int par, strokes;
cin >> par >> strokes;
if (par == 0) break ;
cout << "Hole #" << holeNumber << "\n";
if (strokes == 1) cout << "Hole-in-one.\n";
else if (strokes <= par - 3) cout << "Double eagle.\n";
else if (strokes == par - 2) cout << "Eagle.\n";
else if (strokes == par - 1) cout << "Birdie.\n";
else if (strokes == par) cout << "Par.\n";
else if (strokes == par + 1) cout << "Bogey.\n";
else cout << "Double Bogey.\n";
cout << "\n";
holeNumber++;
}
return 0;
}