cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Finding two highest numbers.
Finding two highest numbers.
Jun 13, 2012 at 9:35pm UTC
MACARENAB
(1)
I'm trying to figure out the two highest numbers of an array.
Without sorting them and only using one loop.
I know how to find the highest, but then how do i skip that number then check for the next highest.
Jun 13, 2012 at 9:39pm UTC
vlad from moscow
(6539)
It is very simple. All that you need is to write the corresponding algorithm.:)
Something as
int max1, max2;
max1 = max2 = a[0];
And then you should compare every next element of the array with max1 and then with max2.:)
Topic archived. No new replies allowed.