Advertisement
Spocoman

Easter Competition

Sep 17th, 2023
878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int easterBreadCount;
  8.     cin >> easterBreadCount;
  9.  
  10.     string baker, command, topBaker = "";
  11.     int topPoints = 0;
  12.  
  13.     for (int i = 0; i < easterBreadCount; i++) {
  14.         cin.ignore();
  15.         getline(cin, baker);
  16.         int bakerpoints = 0;
  17.  
  18.         while (true) {
  19.             cin >> command;
  20.             if (command == "Stop") {
  21.                 break;
  22.             }
  23.             bakerpoints += stoi(command);
  24.         }
  25.  
  26.         if (topPoints < bakerpoints) {
  27.             topBaker = baker;
  28.             topPoints = bakerpoints;
  29.             cout << topBaker << " has " << topPoints << " points.\n"
  30.                 << topBaker << " is the new number 1!\n";
  31.         }
  32.         else {
  33.             cout << baker << " has " << bakerpoints << " points.\n";
  34.         }
  35.     }
  36.    
  37.     cout << topBaker << " won competition with " << topPoints << " points!";
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement