So i manage to find the largest and smallest number. How do i find the mid number in 3 of my arrays?
EXAMPLE :
powerConsumptionJuly[]={144,132,152,123};
powerConsumptionAug[]={123,132,152,123};
powerConsumptionSep]={152,132,152,123};
So the top three should be 144 as Top1, 152 as top 2 and 123 as top 3. The top2 is my MID number.
This is my code in finding the largest and smallest. How do i find the mid number?
// July
if (powerConsumptionJuly[j]> top1)
top1 = powerConsumptionJuly[j];
if (powerConsumptionJuly[j]<top2)
top2 = powerConsumptionJuly[j];
//August
if (powerConsumptionAug[j]>top1)
top1 = powerConsumptionAug[j];
if (powerConsumptionAug[j]<top2)
top2 = powerConsumptionAug[j];
//September
if (powerConsumptionSep[j]> top1)
top1 = powerConsumptionSep[j];
if (powerConsumptionSep[j]<top2)
top2 = powerConsumptionSep[j];
Last edited on
I assume you mean the median.
One way is to sort the array, then simply get the middle value. If size of array is even, then simply take the average of the middle two values.
Arslan, my array doest not involve any requirement to divide or so. Just displaying the 2nd highest and 3rd highest number.
http://www.cplusplus.com/forum/general/195694/
http://www.cplusplus.com/forum/general/195734/
Last edited on