Docsity

Programming - Extraordinary exam June 2020, second part, Exámenes de Programación Informática

Toggle sidebar
bg1
1
UNIVERSIDAD CARLOS III DE MADRID
PROGRAMMING. BACHELOR IN AEROSPACE ENGINEERING
EXTRAORDINARY EXAM - JUNE 2020. SECOND PART. EXERCISE.
Surname(s): ______________________________________
Name: _______________________________________
Signature: _____________________________________
PART 2: EXERCISE. Duration: 1 hour and 30 minutes.
Exercise (7.5 points)
We want to design a MATLAB program to simulate the next Euro Basketball Cup in 2022. Let’s suppose that
a total of 24 national teams will participate in the championship, with a maximum of 12 players by team.
Each team is modelled by means of a data structure that contains the following information:
• An identifier for the team (integer number between 1 and 24)
• Name of the country
• Leader of a group (integer number, 0=false and 1=true)
• FIBA coefficient (float number that models the quality of a team)
• An array with the data corresponding to the basketball players in the team.
• Number of players inscribed for this team (integer between 1 and 12)
In addition, each basketball player is modelled by means of a data structure that contains the following
information:
• Identifier of the basketball player (integer number between 1 and 12)
• Name of the player
• Points scored during the championship.
It is required:
a) [1 point] Define the data structures required to represent the described information to manage the
championship.
b) [1.5 points] Define a function that uses the screen to ask for the data of all the national teams
participating in the Euro Cup. Only the name, the FIBA coefficient and the basketball players must be
introduced by the user. The rest of the fields must be filled automatically. The selections with identifier
between 1 and 4 will be leaders of a group. The program must ask for the user to introduce the data for
the players of each team. After introducing one player, the program must ask for the user if he/she
wants to add another, never exceeding the maximum of 12 players by team. The points scored by each
player must be initialized to 0 and the identifier must be assigned automatically depending on the order
which each player is being introduced.
The function must have the following header:
function teams = addTeams(teams, numTeams, maxPlayersByTeam,
numGroups)
c) [1 point] The national teams must be initially divided in 4 groups containing 6 teams each one. This will
be represented in our program by means of a matrix. Each row will correspond with a group, and each
pf2

Vista previa parcial del texto

¡Descarga Programming - Extraordinary exam June 2020, second part y más Exámenes en PDF de Programación Informática solo en Docsity!

UNIVERSIDAD CARLOS III DE MADRID

PROGRAMMING. BACHELOR IN AEROSPACE ENGINEERING

EXTRAORDINARY EXAM - JUNE 2020. SECOND PART. EXERCISE.

Surname(s): ______________________________________

Name: _______________________________________

Signature: _____________________________________

PART 2: EXERCISE. Duration: 1 hour and 30 minutes.

Exercise ( 7 .5 points)

We want to design a MATLAB program to simulate the next Euro Basketball Cup in 2022. Let’s suppose that a total of 24 national teams will participate in the championship, with a maximum of 12 players by team. Each team is modelled by means of a data structure that contains the following information:

  • An identifier for the team (integer number between 1 and 24 )
  • Name of the country
  • Leader of a group (integer number, 0=false and 1=true)
  • FIBA coefficient (float number that models the quality of a team)
  • An array with the data corresponding to the basketball players in the team.
  • Number of players inscribed for this team (integer between 1 and 1 2) In addition, each basketball player is modelled by means of a data structure that contains the following information:
  • Identifier of the basketball player (integer number between 1 and 12 )
  • Name of the player
  • Points scored during the championship. It is required: a) [1 point] Define the data structures required to represent the described information to manage the championship. b) [1.5 points] Define a function that uses the screen to ask for the data of all the national teams participating in the Euro Cup. Only the name, the FIBA coefficient and the basketball players must be introduced by the user. The rest of the fields must be filled automatically. The selections with identifier between 1 and 4 will be leaders of a group. The program must ask for the user to introduce the data for the players of each team. After introducing one player, the program must ask for the user if he/she wants to add another, never exceeding the maximum of 1 2 players by team. The points scored by each player must be initialized to 0 and the identifier must be assigned automatically depending on the order which each player is being introduced. The function must have the following header: function teams = addTeams(teams, numTeams, maxPlayersByTeam, numGroups) c) [1 point] The national teams must be initially divided in 4 groups containing 6 teams each one. This will be represented in our program by means of a matrix. Each row will correspond with a group, and each

cell will contain the identifier of the team. It is required to write the code of a function that automatically generates this matrix considering the following requirements:

  1. Each group must only contain a national team that is leader of a group (there are only 4 in the championship).
  2. Each team can be included in only one group.
  3. All the teams inscribed must be assigned to a group The function must have the following header: function groups = generateGroups(teams, numGroups, teamsByGroup) d) [ 1 point] Design a function to determine the winner of each group after the initial phase. We are going to consider that the winner of a group is directly the selection of the group with the higher FIBA coefficient in the corresponding field. The function must have the following header: function winners = first_phase_winners (teams, groups, numGroups, teamsByGroup, winners) e) [ 1 point] Let’s suppose that the points scored by each player has been updated at the end of the initial phase of the championship. It is required to design a function to order the players of a national team according to their scored points in decreasing order, using for that the Selection Sort algorithm. The function must have the following header: function sortedPlayers = sort_players (players, numPlayers) f) [ 2 points] Finally, design the main program according to the following set of steps:
  4. [0.2 points] Require the user to complete the data of the national teams that participate in the championship.
  5. [0.3 points] Make a simulation of the initial phase of the championship (create the matrix of groups and determine the winner of each one of them).
  6. [0.75 points] Print the name of the winning national team of each group after the initial phase.
  7. [0.75 points] Print the name of the maximum points scorer of the winning national team of each group after the initial phase.