Golf

来源:互联网 发布:剑灵人女身材数据 编辑:程序博客网 时间:2024/05/17 00:53

FJNU.1859

Description
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 "par" for every hole, and practically all scores are expressed relative to the par. Examples are terms like "par", "birdie" (1 below par) and "bogey" (1 over par), and, in rare cases, "hole-in-one", "eagle" (2 below par), "double eagle" (3 below par) and "double bogey" (2 over par). Although it is possible to get worse than a double bogey and there are names for those, too, we will just assume that most people will cheat and just write down "double bogey", anyway.
John has just joined a golf club and is new to all these names. On his first visit to the golf course, he just fills in the number of strokes for every hole in his score card. He now needs these numbers translated into their proper names.
As John's caddy, you are to write a program that, given the par for a hole and the number of strokes John wrote down, prints the proper name of the score. Make sure that you write a "hole-in-one" even if another description would fit as well.

Input
The input consists of several test cases. Each test case consists of a single line that contains two integers p and s, where p is the par for the hole (either 3, 4, or 5) and s is the number of strokes John needed that that hole, 1 <= s < 20.
The input ends with a hole having p = 0, which should not be processed.

Output
For each test case, output a line containing the number of the hole ('Hole #1', 'Hole #2', etc.).
On the next line print the proper name of the score, followed by a period, i.e. one of 'Hole-in-one.', 'Double Eagle.', 'Eagle.', 'Birdie.', 'Par.', 'Bogey.', or 'Double Bogey.'.
Output a blank line after each hole.

Sample Input
5 3
3 1
4 7
0 0

Sample Output
Hole #1
Eagle.

Hole #2
Hole-in-one.

Hole #3
Double Bogey.

Source
Southwestern Europe 1996, Practice

My Program

#include<iostream>
#define N 100
using namespace std;

int main()
{
    
int p[N],s[N];
    
int n=0,i,d;
    
while(true)
    
{
        cin
>>p[n]>>s[n];
        
if(p[n]==0)
            
break;
        n
++;
    }

    
for(i=0;i<n;i++)
    
{
        cout
<<"Hole #"<<i+1<<endl;
        
if(s[i]==1)
            cout
<<"Hole-in-one."<<endl;
        
else
        
{
            d
=s[i]-p[i];
            
if(d==0)
                cout
<<"Par."<<endl;
            
else
                
if(d>0)
                
{
                    
if(d==1)
                        cout
<<"Bogey."<<endl;
                    
else
                        cout
<<"Double Bogey."<<endl;
                }

                
else
                
{
                    
if(d==-1)
                        cout
<<"Birdie."<<endl;
                    
else    
                        
if(d==-2)
                            cout
<<"Eagle."<<endl;
                        
else
                            
if(d<=-3)
                                cout
<<"Double Eagle."<<endl;
                }

        }

        cout
<<endl;
    }

    
return 0;
}

 
YOYO's Note:
┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄它是华丽的分隔线

【题意简述】

输入标准杆数和John进球的杆数,打等级。


【粗略分析】

简单题,按题目的要求判断结果就可以了。


【C++源代码】

#include<iostream>
#define N 100
using namespace std;

int main()
{
    
int p[N],s[N];
    
int n=0,i,d;
    
while(true)
    
{
        cin
>>p[n]>>s[n];
        
if(p[n]==0)
            
break;
        n
++;
    }

    
for(i=0;i<n;i++)
    
{
        cout
<<"Hole #"<<i+1<<endl;
        
if(s[i]==1)
            cout
<<"Hole-in-one."<<endl;
        
else
        
{
            d
=s[i]-p[i];
            
if(d==0)
                cout
<<"Par."<<endl;
            
else
                
if(d>0)
                
{
                    
if(d==1)
                        cout
<<"Bogey."<<endl;
                    
else
                        cout
<<"Double Bogey."<<endl;
                }

                
else
                
{
                    
if(d==-1)
                        cout
<<"Birdie."<<endl;
                    
else    
                        
if(d==-2)
                            cout
<<"Eagle."<<endl;
                        
else
                            
if(d<=-3)
                                cout
<<"Double Eagle."<<endl;
                }

        }

        cout
<<endl;
    }

    
return 0;
}

【注意事项】

※ 输出完每个测试例记得要换行。


【点评】

 没什么好说的…………

原创粉丝点击