Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int n, countForHearthStone = 0, countForFornite = 0, countForOverWatch = 0, countForOthers = 0;
- cin >> n;
- double originaN = n;
- cin.ignore();
- while (n > 0) {
- string input;
- getline(cin, input);
- if (input == "Hearthstone")
- {
- countForHearthStone++;
- }
- else if (input == "Fornite")
- {
- countForFornite++;
- }
- else if (input == "Overwatch")
- {
- countForOverWatch++;
- }
- else
- {
- countForOthers++;
- }
- n--;
- }
- cout.setf(ios::fixed);
- cout.precision(2);
- double result1 = (countForHearthStone * 100) / originaN*1.00;
- double result2 = (countForFornite * 100) / originaN;
- double result3 = (countForOverWatch * 100) / originaN;
- double result4 = (countForOthers * 100) / originaN;
- cout << "Hearthstone - " << result1 << "%" << endl;
- cout << "Fornite - " << result2 << "%" << endl;
- cout << "Overwatch - " << result3 << "%" << endl;
- cout << "Others - " << result4 << "%" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement