Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int countVisitors;
- cin >> countVisitors;
- cin.ignore();
- //за всеки един посетител
- //повтаряме: въвежда дейността
- //начало: първи посетител (1)
- //край: последния посетител (countVisitors)
- //промяна: +1
- int countBack = 0, countChest = 0, countLegs = 0, countAbs = 0, countShake = 0, countBar = 0;
- for (int visitor = 1; visitor <= countVisitors; visitor++)
- {
- string activity; //"Back", "Chest", "Legs", "Abs", "Protein shake" или "Protein bar"
- getline(cin, activity);
- //проверка каква дейност имаме
- if (activity == "Back")
- {
- countBack++;
- }
- else if (activity == "Chest")
- {
- countChest++;
- }
- else if (activity == "Legs")
- {
- countLegs++;
- }
- else if (activity == "Abs")
- {
- countAbs++;
- }
- else if (activity == "Protein shake")
- {
- countShake++;
- }
- else if (activity == "Protein bar")
- {
- countBar++;
- }
- }
- cout << countBack << " - back" << endl;
- cout << countChest << " - chest" << endl;
- cout << countLegs << " - legs" << endl;
- cout << countAbs << " - abs" << endl;
- cout << countShake << " - protein shake" << endl;
- cout << countBar << " - protein bar" << endl;
- cout.setf(ios::fixed);
- cout.precision(2);
- //какъв процент от всички тренират
- int countTrain = countBack + countChest + countAbs + countLegs; //брой трениращи
- double percentTrain = (countTrain * 1.0 / countVisitors) * 100;
- cout << percentTrain << "% - work out" << endl;
- //какъв процент от всички са купували
- int countBuy = countShake + countBar; //брой пазаруващи
- double percentBuy = (countBuy * 1.0 / countVisitors) * 100;
- cout << percentBuy << "% - protein" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement