Hi @all!
I have a array with three numbers:
num[0] = 5
num[1] = 2
num[2] = 5
I need to find out which of these numbers are the largest ones, it could be one, two or all of them, and need the index. Here for example "0 and 2". What's the best (most compact) way for that?
Thanks a lot.
rob
rob211
0
Newbie Poster
Recommended Answers
Jump to PostUse a for loop to look at the numbers one at a time and save the largest ones.
If you are saving the indexes and there can be more than one, you will need another array to save the indexes in.
Jump to PostHi kolibrizas
Your help, advice, and assistance are very welcome here. But please don't just post solutions to people's homework for them to copy & paste. All they learn from that is how to cheat. Give them guidance that allows them to learn how to do it for themselves. Thanks.
All 8 Replies
NormR1
563
Posting Sage
Team Colleague
kolibrizas
12
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
kolibrizas
12
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
kolibrizas
12
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
rob211
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.