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