desislava_topuzakova

Untitled

Feb 18th, 2023
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int countKozunaks;
  9. cin >> countKozunaks;
  10. cin.ignore();
  11.  
  12. int maxPoints = INT_MIN; //броят на максималните точки
  13. string maxBaker = "";
  14. for (int kozunak = 1; kozunak <= countKozunaks; kozunak++)
  15. {
  16. string baker;
  17. getline(cin, baker);
  18. int totalPoints = 0;
  19. string command; //оценка(5) или Stop
  20. getline(cin, command);
  21. while(command != "Stop") {
  22. //оценка -> "10" -> 10
  23. int grade = stoi(command);
  24. totalPoints += grade;
  25.  
  26. getline(cin, command);
  27. }
  28. //общ брой точки за пекар
  29. cout << baker << " has " << totalPoints << " points." << endl;
  30. //проверка дали точките на този пекар са максималните
  31. if (totalPoints > maxPoints) {
  32. maxPoints = totalPoints;
  33. maxBaker = baker;
  34. cout << baker << " is the new number 1!" << endl;
  35. }
  36. }
  37.  
  38. cout << maxBaker << " won competition with " << maxPoints << " points!" << endl;
  39.  
  40.  
  41.  
  42. }
Add Comment
Please, Sign In to add comment