Question: c++ Integer numElements is read from input. Then, numElements integers are read and stored in vector yesterdayRatings, and numElements integers are read and stored in

c++ Integer numElements is read from input. Then, numElements integers are read and stored in vector yesterdayRatings, and numElements integers are read and stored in vector todayRatings. Perform the following tasks:

If yesterdayRatings is equal to todayRatings, output "Today's ratings are the same as yesterday's ratings."

Otherwise, output "Today's ratings are not the same as yesterday's ratings."

Assign todayBackup as a copy of todayRatings.

Ex: If the input is 4 114 148 179 62 96 108 61 167, then the output is:

Yesterday's ratings: 114 148 179 62

Today's ratings: 96 108 61 167

Today's ratings are not the same as yesterday's ratings.

Today's backup: 96 108 61 167

code:

#include

#include using namespace std;

int main() {

int numElements;

unsigned int i;

vector yesterdayRatings;

vector todayRatings;

vector todayBackup;

cin >> numElements;

yesterdayRatings.resize(numElements);

todayRatings.resize(numElements);

cout << "Yesterday's ratings: ";

for (i = 0; i < yesterdayRatings.size(); ++i) {

cin >> yesterdayRatings.at(i);

cout << yesterdayRatings.at(i) << " ";

}

cout << endl;

cout << "Today's ratings: ";

for (i = 0; i < todayRatings.size(); ++i) {

cin >> todayRatings.at(i);

cout << todayRatings.at(i) << " ";

}

cout << endl;

//your code should be here

cout << "Today's backup: ";

for (i = 0; i < todayBackup.size(); ++i) {

cout << todayBackup.at(i) << " ";

}

cout << endl; return 0;

}

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!