Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » array : minimum value
array : minimum value [message #35624] Wed, 07 March 2012 11:17 Go to previous message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
Hello guys,

I have to find the minimum value into an array of 6 elements... here my solutions:

1)
...
double vet[] = { _a, _b, _c, _d, _e, _f };
double 	r = min(_a, _b);
r= min(r,_c); 
r= min(r,_d);
r= min(r,_e);
r= min(r,_f);

return r; 


2)
double vet[] = { _a, _b, _c, _d, _e, _f };
double min = vet[0];
for (int i=0; i<(sizeof vet/sizeof *vet ); i++)
{
     if(vet[i] < min){ min = vet[i];}
}
return min;


There is an easyer way to do it ?!

thanks Matteo
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Key pressing with MINGW and Windows XP does not work
Next Topic: Problem using more classes...
Goto Forum:
  


Current Time: Thu Apr 25 15:42:20 CEST 2024

Total time taken to generate the page: 0.01477 seconds