Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- int movieCount;
- cin >> movieCount;
- double rating, maxRating = 0, minRating = 10, totalRating = 0;
- string movie, maxMovie = "", minMovie = "";
- for (int i = 0; i < movieCount; i++) {
- cin.ignore();
- getline(cin, movie);
- cin >> rating;
- if (rating > maxRating) {
- maxMovie = movie;
- maxRating = rating;
- }
- if (rating < minRating) {
- minMovie = movie;
- minRating = rating;
- }
- totalRating += rating;
- }
- printf("%s is with highest rating: %.1f\n", maxMovie.c_str(), maxRating);
- printf("%s is with lowest rating: %.1f\n", minMovie.c_str(), minRating);
- printf("Average rating: %.1f\n", totalRating / movieCount);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement