Skip to content

Instantly share code, notes, and snippets.

@Florian3k
Created March 21, 2018 20:48
Show Gist options
  • Select an option

  • Save Florian3k/b1790060ec7d004a0f588989d76279ce to your computer and use it in GitHub Desktop.

Select an option

Save Florian3k/b1790060ec7d004a0f588989d76279ce to your computer and use it in GitHub Desktop.
#include <algorithm>
#include <numeric>
#include <iterator>
int findWinner( float c[30][5] )
{
float maxes[30];
for ( int i = 0; i < 30 ; i++ ) {
auto minmax = std::minmax_element(
std::begin(c[i]),
std::end(c[i])
);
maxes[i] = std::accumulate(
std::begin(c[i]),
std::end(c[i]),
0
) - *minmax.first - *minmax.second;
}
return std::distance(
std::begin(maxes),
std::max_element(
std::begin(maxes),
std::end(maxes),
[](int a, int b){return a < b;}
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment