Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- using namespace std;
- int main() {
- int volume, hearthstones = 0, fornites = 0, overwatches = 0, others = 0;
- cin >> volume;
- cin.ignore();
- string game;
- for (int i = 0; i < volume; i++) {
- getline(cin, game);
- if (game == "Hearthstone") {
- hearthstones++;
- }
- else if(game == "Fornite") {
- fornites++;
- }
- else if(game == "Overwatch") {
- overwatches++;
- }
- else {
- others++;
- }
- }
- cout << fixed << setprecision(2)
- << "Hearthstone - " << 100.0 * hearthstones / volume << "%\n"
- << "Fornite - " << 100.0 * fornites / volume << "%\n"
- << "Overwatch - " << 100.0 * overwatches / volume << "%\n"
- << "Others - " << 100.0 * others / volume << "%\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement