Advertisement
DidiMilikina

Untitled

Nov 4th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.     double capacitet;
  10.     double numberFans;
  11.     cin >> capacitet >> numberFans;
  12.  
  13.     double prSectorA = 0.0;
  14.     double prSectorB = 0.0;
  15.     double prSectorV = 0.0;
  16.     double prSectorG = 0.0;
  17.  
  18.     for (int i = 0; i < numberFans; i++)
  19.     {
  20.         string sector;
  21.         cin >> sector;
  22.  
  23.         if (sector == "A")
  24.         {
  25.             prSectorA++;
  26.         }
  27.         else if (sector == "B")
  28.         {
  29.             prSectorB++;
  30.         }
  31.         else if (sector == "V")
  32.         {
  33.             prSectorV++;
  34.         }
  35.         else if (sector == "G")
  36.         {
  37.             prSectorG++;
  38.         }
  39.  
  40.     }
  41.  
  42.     double percentsA = prSectorA / numberFans * 100;
  43.     double percentsB = prSectorB / numberFans * 100;
  44.     double percentsV = prSectorV / numberFans * 100;
  45.     double percentsG = prSectorG / numberFans * 100;
  46.  
  47.     double totalFans = numberFans / capacitet * 100;
  48.  
  49.     cout << fixed << setprecision(2) << percentsA << "%" << endl;
  50.     cout << fixed << setprecision(2) << percentsB << "%" << endl;
  51.     cout << fixed << setprecision(2) << percentsV<< "%" << endl;
  52.     cout << fixed << setprecision(2) << percentsG<< "%" << endl;
  53.     cout << fixed << setprecision(2) << totalFans<< "%" << endl;
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement