Guest User

Untitled

a guest
May 16th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string.h>
  4. using namespace std;
  5. class Competitor
  6. {
  7. char country[100];
  8. char team[32];
  9. char name[100];
  10. int number;
  11. int age[2];
  12. int height[3];
  13. int weight[3];
  14. public:
  15. void fillData();
  16. void showData();
  17. };
  18. int main()
  19. {
  20. setlocale(LC_ALL, "rus");
  21. system("chcp 1251");
  22. int const N = 2;
  23. Competitor obj[N];
  24. cout << "Внесите данные об участниках спортивных соревнований" << endl;
  25. for (int i = 0; i < N; i++)
  26. obj[i].fillData();
  27. for (int i = 0; i < N; i++)
  28. obj[i].showData();
  29. system("pause");
  30. return 0;
  31. }
  32. void Competitor::fillData()
  33. {
  34. cout << "Страна: ";
  35. cin.getline(country, 100);
  36. cout << "Название команды: ";
  37. cin.getline(team, 32);
  38. cout << "Ф.И. игрока: ";
  39. cin.getline(name, 100);
  40. cout << "Игровой номер: ";
  41. cin >> number;
  42. cout << "Возраст игрока: ";
  43. cin >> age[2];
  44. cout << "Рост игрока: ";
  45. cin >> height[3];
  46. cout << "Вес игрока: ";
  47. cin >> weight[3];
  48. cin.get();
  49. cout << endl;
  50. }
  51.  
  52. void Competitor::showData()
  53. {
  54. // Здесь нужно вывести информацию о самой молодой (по возрасту), рослой (по росту) и легкой (по весу) команде.
  55. cout << "Страна: " << country << " | Название команды: " << team << " | Ф.И. игрока: " << name << " | Игровой номер: " << number << " | Возраст: " << age << " | Рост: " << height << " | Вес: " << weight << endl;
  56. }
  57.  
  58. std::min_element();
  59. std::max_element();
  60.  
  61. std::min_element(age, age+sz); // sz - размер вашего массива. Стоит заметить, что функция вернет указатель на элемент
Add Comment
Please, Sign In to add comment