Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string movie, bestMovie = "";
- getline(cin, movie);
- int counter = 0, bestAscii = 0;
- while (movie != "STOP" && ++counter < 7) {
- int currentAscii = 0;
- for (int j = 0; j < movie.length(); j++) {
- currentAscii += movie[j];
- if (movie[j] > 96 && movie[j] < 123) {
- currentAscii -= movie.length() * 2;
- }
- else if (movie[j] > 64 && movie[j] < 91) {
- currentAscii -= movie.length();
- }
- }
- if (currentAscii > bestAscii) {
- bestAscii = currentAscii;
- bestMovie = movie;
- }
- getline(cin, movie);
- }
- if (counter == 7) {
- cout << "The limit is reached.\n";
- }
- cout << "The best movie for you is " << bestMovie << " with " << bestAscii << " ASCII sum.\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement