Closed

Got it working. Thanks for the help.
Last edited on
What was you input?
You need to check for fail before you do the calculation. And do not calculate when it fails, just break the loop.
You set the min from the first input.
You don't set the max from the first input.
What if all inputs are negative values? All < 0? Your max stays 0.

You don't need to treat the first value differently, if the initial values of min and max are set wisely.
See http://www.cplusplus.com/reference/limits/numeric_limits/
1
2
int max = std::numeric_limits<int>::min(); // no input can be less than this
int min = std::numeric_limits<int>::max(); // no input can be more than this 
Topic archived. No new replies allowed.