Advertisement
Spocoman

Gold Mine

Sep 20th, 2023
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int locations;
  7.     cin >> locations;
  8.  
  9.     for (int i = 0; i < locations; i++) {
  10.         double averageGold, gold, goldSum = 0;
  11.         cin >> averageGold;
  12.  
  13.         int dayDigging;
  14.         cin >> dayDigging;
  15.  
  16.         for (int j = 0; j < dayDigging; j++) {
  17.             cin >> gold;
  18.             goldSum += gold;
  19.         }
  20.  
  21.         cout.setf(ios::fixed);
  22.         cout.precision(2);
  23.  
  24.         if (goldSum / dayDigging >= averageGold) {
  25.             cout << "Good job! Average gold per day: " << goldSum / dayDigging << ".\n";
  26.         }
  27.         else {
  28.             cout << "You need " << averageGold - (goldSum / dayDigging) << " gold.\n";
  29.         }
  30.     }
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement