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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started