Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <list>
- using namespace std;
- struct VideoLibrary {
- string title;
- unsigned int cost;
- string producer;
- };
- int main() {
- char choice;
- list<VideoLibrary> movies;
- VideoLibrary movie;
- unsigned int total_cost = 0;
- do {
- cout << "Enter title: ";
- getline(cin, movie.title);
- cout << "Enter cost: ";
- cin >> movie.cost;
- total_cost += movie.cost;
- cout << "Enter producer name: ";
- cin.ignore(1);
- getline(cin, movie.producer);
- movies.push_back(movie);
- cout << "Add one more movie? (y/n): ";
- cin >> choice;
- cin.ignore(1);
- } while (choice == 'y');
- cout << "\n\n";
- cout << "Movies with cost lower than mean:" << endl;
- for(auto it : movies) {
- if (it.cost < (total_cost / movies.size())) {
- cout << it.producer << " - " << it.title;
- cout << " (" << it.cost << ")" << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement