Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- int easterBreadCount;
- cin >> easterBreadCount;
- string baker, command, topBaker = "";
- int topPoints = 0;
- for (int i = 0; i < easterBreadCount; i++) {
- cin.ignore();
- getline(cin, baker);
- int bakerpoints = 0;
- while (true) {
- cin >> command;
- if (command == "Stop") {
- break;
- }
- bakerpoints += stoi(command);
- }
- if (topPoints < bakerpoints) {
- topBaker = baker;
- topPoints = bakerpoints;
- cout << topBaker << " has " << topPoints << " points.\n"
- << topBaker << " is the new number 1!\n";
- }
- else {
- cout << baker << " has " << bakerpoints << " points.\n";
- }
- }
- cout << topBaker << " won competition with " << topPoints << " points!";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement