Advertisement
Spocoman

PC Game Shop

Sep 21st, 2023 (edited)
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int volume, hearthstones = 0, fornites = 0, overwatches = 0, others = 0;
  9.     cin >> volume;
  10.     cin.ignore();
  11.  
  12.     string game;
  13.  
  14.     for (int i = 0; i < volume; i++) {
  15.         getline(cin, game);
  16.  
  17.         if (game == "Hearthstone") {
  18.             hearthstones++;
  19.         }
  20.         else if(game == "Fornite") {
  21.             fornites++;
  22.         }
  23.         else if(game == "Overwatch") {
  24.             overwatches++;
  25.         }
  26.         else {
  27.             others++;
  28.         }
  29.     }
  30.  
  31.     cout << fixed << setprecision(2)
  32.         << "Hearthstone - " << 100.0 * hearthstones / volume << "%\n"
  33.         << "Fornite - " << 100.0 * fornites / volume << "%\n"
  34.         << "Overwatch - " << 100.0 * overwatches / volume << "%\n"
  35.         << "Others - " << 100.0 * others / volume << "%\n";
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement