编程介的小学生 2019-09-15 17:04 采纳率: 20.5%
浏览 71

A Day at the Races 代码的一个实现

Problem Description
Formula One is the highest class of car racing sports. A typical Formula One season consists of a series of races called ``Grands Prix" which constructors like Ferrari, Renault, etc. and others participate with one or more cars driven by the best drivers in the world. During the season, teams compete in two parallel championships: the drivers championship and the teams championship.

In the drivers championship, drivers compete to achieve the maximum total number of points by the end of the season, the rules of the competition states that the top eight drivers at each Grand Prix receive 10,8,6,5,4,3,2,1 points respectively. In case of points tie, the driver with the highest number of first places leads. If still tied, then the highest second places, and so on till the highest 8th places. If still tied, then drivers are sorted lexicographically by their last and then by their first names.

After each race, the points received by each driver are added to his team's pocket, and at the end of the season the team with the highest number of points wins the teams championship. To add excitement to the season, team sponsors are allowed to buy drivers from other teams even within the same season. In case of points tie between teams, teams are sorted lexicographically by their names. In this problem, you are given data of a formula one season and you're asked to process these data according to the rules above to determine both the drivers and teams standings.

Input
Your program will be tested on one or more data-sets, each representing a Formula One season. All input lines are 255 characters or less. Studying the sample I/O you'll discover that the first line of each season has an integer N , where 0 < N < 32 and representing the number of Grands Prix in that season. For each Grand Prix, the name of the Grand Prix appears on a line by itself (maximum length is 64 characters) followed by a table of the first name, last name and team name of the top eight drivers, from 1 to 8, in that Grand Prix. Each of the first and last names is a sequence of printable ASCII characters, no longer than 12 characters, and contains no spaces. Each team name is a sequence of printable ASCII characters, no longer than 18 characters, and may contain spaces (but no leading or trailing spaces.) Each team name is followed by a single period `.' which is not part of the name. Trailing white space may follow. A line of three -'s follows the listing of each Grand Prix. The last line of the input file contains a single zero.

Output
For each data set in the input you must print Season k :" where k is the data-set number (starting from 1.) The next line must stateDrivers Standing:". On subsequent lines list the drivers standing for that season. For each driver, print their first and last names separated by exactly one space and left justified in a field of width 25, followed by a single space, followed by the total number of points achieved by the driver during the season. The drivers standing should be followed by a blank line.

The next line must state ``Teams Standing:" On subsequent lines list the teams standing for the that season. For each team, print the team name left justified in a field of width 25, followed by a single space, followed by the total number of points the team has scored during the season. The teams standing should be followed by a blank line.

Sample Input
2
FORMULA 1 Gran Premio Telefonica de Espana 2006
Pos Driver Team
1 Fernando Alonso Renault.
2 Michael Schumacher Ferrari.
3 Giancarlo Fisichella Renault.
4 Felipe Massa Ferrari.
5 Kimi Raikkonen McLaren-Mercedes.
6 Jenson Button Honda.
7 Rubens Barrichello Honda.

8 Nick Heidfeld Sauber-BMW.

FORMULA 1 Grand Prix de Monaco 2006
Pos Driver Team
1 Fernando Alonso Renault.
2 Jaun-Pablo Montoya McLaren-Mercedes.
3 David Coulthard RBR-Ferrari.
4 Rubens Barrichello Honda.
5 Michael Schumacher Ferrari.
6 Giancarlo Fisichella Renault.
7 Nick Heidfeld Sauber-BMW.

8 Ralf Schumacher Toyota.

0

Sample Output
Season 1:
Drivers Standing:
Fernando Alonso 20
Michael Schumacher 12
Giancarlo Fisichella 9
Jaun-Pablo Montoya 8
Rubens Barrichello 7
David Coulthard 6
Felipe Massa 5
Kimi Raikkonen 4
Jenson Button 3
Nick Heidfeld 3
Ralf Schumacher 1

Teams Standing:
Renault 29
Ferrari 17
McLaren-Mercedes 12
Honda 10
RBR-Ferrari 6
Sauber-BMW 3
Toyota 1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Arcgis相交分析无法绘制一个或多个图形
    • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
    • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
    • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
    • ¥30 3天&7天&&15天&销量如何统计同一行
    • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
    • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
    • ¥15 vs2019中数据导出问题
    • ¥20 云服务Linux系统TCP-MSS值修改?
    • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)