Skip to main content
11 events
when toggle format what by license comment
Nov 15, 2022 at 11:13 history edited Edward CC BY-SA 4.0
fix typo
Nov 15, 2022 at 9:23 comment added Toby Speight In modern C++, I'd replace that loop with a range-based one for (auto value: std::ranges::istream_view<float>{std::cin} | std::ranges::take_view{N}). The only downside (not relevant here) is that it will over-read by one element (incrementing its iterator before take_view calls a halt).
Nov 15, 2022 at 9:20 history edited Toby Speight CC BY-SA 4.0
Typo fixes
Nov 15, 2022 at 1:07 vote accept soupless
Nov 14, 2022 at 20:06 comment added Edward I've updated my answer to suggest an alternative algorithm.
Nov 14, 2022 at 20:05 history edited Edward CC BY-SA 4.0
added generic algorithm
Nov 14, 2022 at 19:00 comment added Edward It's hard to say without knowing all of your current restrictions. One could easily make only a single pass through the data, extracting value, count pairs, and then make a single pass through the pairs to find the max count value. If you can't use a struct, it's not going to be very pretty.
Nov 14, 2022 at 18:47 comment added soupless Also, I asked this from one of the answerers but no one responded yet: How bad is my method of grouping while getting the input? I can see how it's bad because it's nested loops, but I can't see the actual badness of it.
Nov 14, 2022 at 18:46 comment added Edward Oh, I really hope it's at least C++11 or they are doing you a disservice by teaching you an obsolete language.
Nov 14, 2022 at 18:43 comment added soupless We haven't really dived in modern C++ features, since we use the "default" C++. Not sure what version it is, but maybe it's C++98.
Nov 14, 2022 at 18:41 history answered Edward CC BY-SA 4.0