联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2018-08-04 04:48


1. Problem 1077

Title: Birthday Lookup

Description

In this assignment, you will need to create a 'database' of birthdays that will be queried repeatedly.

First, a (non-specified) number of birthdays + names is specified. You will need to store this data in a binary

search tree (BST). The nodes of the BST will contain the (birthday, name) pairs.

Once the birthdays are stored, a number of queries follows. These take the shape of numeric (D-M-YY)

dates. For each queried date you need to return the person that has a birthday on that date, or, if the queried

date is nobodies birthday, the name of the person whose birthday is the first after the query date.

? Each line corresponds to a valid date, and a name. (You do not have to worry about date validation; all

dates in the input are valid dates.)

? Each date consisting of one string ("January", "February", ..., or "December"), one integer between 1

and 31, and one two digit integer representing the year (from 90 to 99, and then from 00 to 16).

? Each name consists of a first name and a last name. (i.e., you do not need to worry about compound

names comprised of more than 2 'words')

? Please use structures to store the dates and names.

? Use malloc to dynamically allocate just enough space for all the data and data structures.

? The access time of binary trees depends on how “balanced” they are. So a perfect solution would deal

with this issue.

Input

? the string “BIRTHDAYS_START”

? followed by the (date, birthday)-pairs

? followed by the string “QUERIES_START”

? followed by a number of user query in format day month year (e.g. “1 1 00” or “31 3 68”).

Output

? the names of persons who have their birthday on the queried dates, or those of the first subsequent

birthdays.

? In the latter case, this should be indicated by pre-pending “first subsequent birthday: ” before the name.

? In the unlikely case that there is no next birthday, you should print “no subsequent birthday”

Sample Input

BIRTHDAYS_START

January 1 01 Molly Mcauliffe

January 1 00 Dennise Nigh

February 28 99 Erma Merrick

July 17 12 Linn Alvin

September 10 12 Delphia Bynum

July 1 00 Vania Jones

June 30 90 Brittney Gemmill

August 25 06 Aubrey Sherard

May 27 08 Marica Rising

October 1 03 Eugena Steele

QUERIES_START

1 1 00

3 7 12

30 6 90

6 7 16

1 1 90

Sample Output

Dennise Nigh

first subsequent birthday: Linn Alvin

Brittney Gemmill

no subsequent birthday

first subsequent birthday: Brittney Gemmill

2. 1079

Title: Football Statistics II

Description

In this assignment, you are asked to process a list of outcomes of football games and process the results.

You can assume that there are only 30 teams, but not much else:

? not every teams need to play against every other team

? some teams might not play a single match

? the number of matches between two teams need not be the same as that between other teams

? the number of home games might be different from the number of away games

? the total number of match results that you may need to process can be small, or very large.

The last point means that you cannot store the entire list of match results in memory, only aggregate

statistics.

Since the statistics are fractional, make sure that you process the data using double precision.

Input

The input consists of:

? The number of matches played

? List of results for each match

Each row in the list has the form

home_team_id away_team_id goals_home_team goals_away_team

where the IDs are integers in the range [0, 29]. That is, you can assume that there are maximally 30 teams.

For instance:

3 8 1 0

encodes a 1-nil win for home team 3 against away team 8, and

16 1 0 0

encodes a draw between teams 16 and 1.

Output

For each team that played at least one match, output a row containing:

1. team id

2. win ratio (= #wins / #plays )

3. win ratio on home games. This should be -1 in case of no home games.

4. average point difference. E.g., "-0.25" would indicate that on average the team lost by 0.25 point per

game.

All fractional output data should be truncated to 3 digits behind the decimal point.

The list needs to be ordered, based on team ID. (How else could it be black box tested?)

Sample Input

6

0 1 5 0

1 0 3 1

0 2 2 2

2 0 4 2

1 2 2 3

2 1 8 0

Sample Output

0 0.250 0.500 0.250

1 0.250 0.500 -3.000

2 0.750 1.000 2.750


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp