Question: C++ Need help sorting an array: these two functions pull data and put it into an array. I need to run loadmovies and sort the

C++ Need help sorting an array: these two functions pull data and put it into an array.

I need to run loadmovies and sort the array based on movies[i].expectedYield (ie 0,1 or 2), and then add the data from LoadRooms

void LoadMovies(Movie movies[]){ //loads movie data from file

int numMovies;

ifstream infile; infile.open("movies.txt"); infile>>numMovies;

for(int i=0; i>movies[i].title; infile>>movies[i].runTime; infile>>movies[i].expectedYield; }

infile.close(); }

void LoadRooms(Movie movies[], int size){ //loads room data from file. ifstream infile; infile.open("rooms.txt");

for(int i=0; i>movies[i].roomID; infile>>movies[i].capacity; movies[i].available = movies[i].capacity;; //initial availability is equal to capacity as no tickets are sold } infile.close(); }

movies.txt

9 Gemini_Man 117.9 2 Joker 122.8 2 Zombieland 99.5 2 Knives_Out 130.1 1 Judy 118.3 0 Downton_Abbey 123.8 0 It 170.0 2 Black_and_Blue 108.4 1 Terminator_Dark_Fate 134.9 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!