Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <math.h>
- using namespace std;
- int main()
- {
- int countKozunaks;
- cin >> countKozunaks;
- cin.ignore();
- int maxPoints = INT_MIN; //броят на максималните точки
- string maxBaker = "";
- for (int kozunak = 1; kozunak <= countKozunaks; kozunak++)
- {
- string baker;
- getline(cin, baker);
- int totalPoints = 0;
- string command; //оценка(5) или Stop
- getline(cin, command);
- while(command != "Stop") {
- //оценка -> "10" -> 10
- int grade = stoi(command);
- totalPoints += grade;
- getline(cin, command);
- }
- //общ брой точки за пекар
- cout << baker << " has " << totalPoints << " points." << endl;
- //проверка дали точките на този пекар са максималните
- if (totalPoints > maxPoints) {
- maxPoints = totalPoints;
- maxBaker = baker;
- cout << baker << " is the new number 1!" << endl;
- }
- }
- cout << maxBaker << " won competition with " << maxPoints << " points!" << endl;
- }
Add Comment
Please, Sign In to add comment