Advertisement
Sanlover

Untitled

Dec 21st, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <Windows.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. SetConsoleOutputCP(1251);
  9. SetConsoleCP(1251);
  10.  
  11. size_t strMarksSize;
  12. cout << "Enter the amount of marks = ";
  13. cin >> strMarksSize;
  14.  
  15. auto marksArray = new pair<int, pair<double, double>>[strMarksSize];
  16.  
  17.  
  18. cout << "Fill data:" << endl;
  19.  
  20. int temp;
  21. for (size_t i = 0; i < strMarksSize; i++)
  22. {
  23. cout << i << ") ";
  24. string skipName;
  25. cin >> marksArray[i].first;
  26. cin >> skipName >> skipName;
  27.  
  28. double min, max, summary = 0;
  29. cin >> min;
  30. max = min;
  31. for (size_t j = 0; j < 7; j++)
  32. {
  33. cin >> temp;
  34. if (temp > max)
  35. {
  36. max = temp;
  37. }
  38. if (temp < min)
  39. {
  40. min = temp;
  41. }
  42. summary += temp;
  43. }
  44. summary -= max;
  45. if (min != max)
  46. {
  47. summary -= min;
  48. }
  49. marksArray[i].second.first = summary;
  50. cin >> min;
  51. max = min;
  52. summary = 0;
  53. for (size_t j = 0; j < 7; j++)
  54. {
  55. cin >> temp;
  56. if (temp > max)
  57. {
  58. max = temp;
  59. }
  60. if (temp < min)
  61. {
  62. min = temp;
  63. }
  64. summary += temp;
  65. }
  66. summary -= max;
  67. if (min != max)
  68. {
  69. summary -= min;
  70. }
  71. marksArray[i].second.second = summary;
  72. }
  73.  
  74. for (size_t i = 0; i < strMarksSize - 1; i++)
  75. {
  76. for (size_t j = 0; j < strMarksSize - i - 1; j++)
  77. {
  78. if (marksArray[j].second.second < marksArray[j + 1].second.second)
  79. {
  80. swap(marksArray[j], marksArray[j + 1]);
  81. }
  82. }
  83. }
  84. string result;
  85. int index = 0, preIndex = 0;
  86. for (size_t i = 0; i < strMarksSize; i++)
  87. {
  88. if (marksArray[i].second.second != marksArray[index].second.second)
  89. {
  90. index = i;
  91. break;
  92. }
  93. result += to_string(marksArray[i].first) + ") первое место " + to_string(marksArray[i].second.second) + '\n';
  94. }
  95. if (index != preIndex)
  96. {
  97. preIndex = index;
  98. for (size_t i = index; i < strMarksSize; i++)
  99. {
  100. if (marksArray[i].second.second != marksArray[index].second.second)
  101. {
  102. index = i;
  103. break;
  104. }
  105. result += to_string(marksArray[i].first) + ") второе место " + to_string(marksArray[i].second.second) +
  106. '\n';
  107. }
  108. if (index != preIndex)
  109. {
  110. for (size_t i = index; i < strMarksSize; i++)
  111. {
  112. if (marksArray[i].second.second != marksArray[index].second.second)
  113. {
  114. index = i;
  115. break;
  116. }
  117. result += to_string(marksArray[i].first) + ") третье место " + to_string(marksArray[i].second.second) +
  118. '\n';
  119. }
  120. }
  121. }
  122. cout << endl << result;
  123. return 0;
  124. }
  125.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement