Program in C that seeks and memorize two maximums in an array

Status
Not open for further replies.

Mejdi_tn

Junior Member level 3
Joined
Oct 20, 2007
Messages
28
Helped
7
Reputation
14
Reaction score
6
Trophy points
1,283
Activity points
1,473
hi
i need programm that seeks two maximum in a array and memorise there position
thing you
 

Re: help C

Search for binary search programs on Google.
 

Re: help C

Is this what you mean?:

for (i = 0; i > arraylength; i++)
{
if (array > max1_index)
{
temp = max1_index;
max1_index= i;
max2_index = temp;
}
else if (array > max2_index)
max2_index = i;
}
 

Re: help C

Thats cool for a start!
 

Re: help C

jhbbunch said:
Is this what you mean?:

for (i = 0; i > arraylength; i++)
{
if (array > max1_index)
{
temp = max1_index;
max1_index= i;
max2_index = temp;
}
else if (array > max2_index)
max2_index = i;
}


First, you need to set max1_index, otherwise you can't say if (array > max1_index)
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…