If you have a list of numbers what would be the best function to find the maximun and min of the numbers I need to make up my own function instead of win32 API
Here''s a macro. Probably not what you are looking for but maybe
it will get you going int he right direction.
#define MAX(a, b) (((a) > (b)) ? (b) : (a))
It only finds the max of two numbers though.
Foxtrot
it will get you going int he right direction.
#define MAX(a, b) (((a) > (b)) ? (b) : (a))
It only finds the max of two numbers though.
Foxtrot
Well, what I'd do is have a variable that contains the highest number so far then compare each number to that number, and if the number being compared is larger than make that the largest number.
Here's some pseudocode.
so if the number being compared is larger then it is considered the max number so far. That way at the end you'd have the largest number of the group.
"'Nazrix is cool' -- Nazrix" --Darkmage --Godfree
Edited by - Nazrix on September 28, 2000 10:23:32 PM
Edited by - Nazrix on September 29, 2000 11:48:34 PM
Here's some pseudocode.
int max;while(not done checking numbers){if (current_number>max) max=current_number; //move to the next number to compare}return max;
so if the number being compared is larger then it is considered the max number so far. That way at the end you'd have the largest number of the group.
"'Nazrix is cool' -- Nazrix" --Darkmage --Godfree
Edited by - Nazrix on September 28, 2000 10:23:32 PM
Edited by - Nazrix on September 29, 2000 11:48:34 PM
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement