fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main() {
  6. cout << fixed << setprecision(2);
  7. int n, m, tmp, sumGl, sumMin, sumMax, valMin, valMax, countMin, countMax;
  8. cin >> n >> m;
  9. for(int j = 0 ; j < m ; j++){
  10. sumGl = sumMin = sumMax = 0;
  11. valMin = 11;
  12. valMax = 0;
  13. countMin = countMax = 0;
  14. for(int i = 0 ; i < n; i++) {
  15. cin >> tmp;
  16. sumGl += tmp;
  17. if(tmp < valMin) {
  18. sumMin = tmp;
  19. valMin = tmp;
  20. countMin = 1;
  21. }
  22. else if(tmp == valMin) {
  23. sumMin += tmp;
  24. countMin++;
  25. }
  26. if(tmp > valMax) {
  27. sumMax = tmp;
  28. valMax =tmp;
  29. countMax = 1;
  30. }
  31. else if(tmp == valMax) {
  32. sumMax += tmp;
  33. countMax++;
  34. }
  35. }
  36. cout << (sumGl - sumMax - sumMin) / (double)(n - countMax - countMin) << " ";
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0s 15232KB
stdin
5 4
7 8 9 8 10
6 5 5 4 7 
9 9 10 7 7
7 7 10 9 8
stdout
8.33 5.33 9.00 8.50