fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. void rateLevelOfObesityBasedOnBmi (float bmi, string forename, vector <string>& peopleWithUnderweight,
  8. vector <string>& peopleWithCorrectWeight,
  9. vector <string>& peopleWtihOverweight);
  10. void showObesityClassificationsOfPeople (vector <string>& peopleWithUnderweight,
  11. vector <string>& peopleWithCorrectWeight,
  12. vector <string>& peopleWtihOverweight);
  13.  
  14. int main()
  15. {
  16. int numberOfPeople;
  17. cin >> numberOfPeople;
  18. string forename;
  19. int weight, height;
  20.  
  21. vector <string> peopleWithUnderweight;
  22. vector <string> peopleWithCorrectWeight;
  23. vector <string> peopleWtihOverweight;
  24.  
  25. for(int i = 0; i < numberOfPeople; i++)
  26. {
  27. cin >> forename;
  28. cin >> weight;
  29. cin >> height;
  30.  
  31. float bmi = (weight / ((height / 100.) * (height / 100.)));
  32. rateLevelOfObesityBasedOnBmi (bmi, forename, peopleWithUnderweight, peopleWithCorrectWeight, peopleWtihOverweight);
  33. }
  34. if (numberOfPeople == 0)
  35. return 0;
  36. showObesityClassificationsOfPeople (peopleWithUnderweight, peopleWithCorrectWeight, peopleWtihOverweight);
  37.  
  38. return 0;
  39. }
  40.  
  41. void rateLevelOfObesityBasedOnBmi (float bmi, string forename, vector <string>& peopleWithUnderweight,
  42. vector <string>& peopleWithCorrectWeight,
  43. vector <string>& peopleWtihOverweight)
  44. {
  45. if (bmi < 18.5)
  46. peopleWithUnderweight.push_back(forename);
  47. else if ((bmi >= 18.5) && (bmi < 25))
  48. peopleWithCorrectWeight.push_back(forename);
  49. else if (bmi >= 25)
  50. peopleWtihOverweight.push_back(forename);
  51. }
  52.  
  53. void showObesityClassificationsOfPeople (vector <string>& peopleWithUnderweight,
  54. vector <string>& peopleWithCorrectWeight,
  55. vector <string>& peopleWtihOverweight)
  56. {
  57. cout << "niedowaga" << '\n';
  58. for(int i = 0; i < peopleWithUnderweight.size(); i++)
  59. cout << peopleWithUnderweight[i] << '\n';
  60.  
  61. cout << '\n';
  62. cout << "waga prawidlowa" << '\n';
  63. for(int i = 0; i < peopleWithCorrectWeight.size(); i++)
  64. cout << peopleWithCorrectWeight[i] << '\n';
  65.  
  66. cout << '\n';
  67. cout << "nadwaga" << '\n';
  68. for(int i = 0; i < peopleWtihOverweight.size(); i++)
  69. cout << peopleWtihOverweight[i] << '\n';
  70. }
  71.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty