By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

Algorithm In C ?

P: 1
i need some help .
the equivalent for algorithm in c .
i know that this is a header in c++ for min, max... but i need it for c

what can i use ?
Feb 25 '07 #1
Share this Question
Share on Google+
1 Reply


DeMan
100+
P: 1,806
Think about how a min/max function should work.

This is language independent, so we can write down (in plain english), what it is that you want to do:
eg. to implement min:
1) take 2 values as input
2) return the greater of these values.

Then we split it down further:
How do we return the greater value:
2.1) compare whether val1 > val2)
2.1.1) if the comparison was true, return val1,
2.1.2) if the comparison was false return val2.

In this case, it probably becomes simple enough to start implementing at this point, however for larger problems, you could continue to refine the problem into easier and easier parts.

If you need more help, then post again. Don't expect a complete answer, however, as the idea here is to help you WORK OUT a solution rather than provide you with one we prepared earlier.....
Feb 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.