C++ exercise: no for-loops

Submitted By: bilderbikkel
Rating: starstarstarstarstar (Rate It)
Share: Share By Email By Email

Visit


Description

Reading the literature, one reads to prefer algorithms over loops (Stroustrup, Sutter). This is easier said than done. In this exercise you must replace for-loops by using a combination of all those algorithm things like std::for_each, std::transform, std::bind1st, std::bind2nd, std::multiplies and more of the likes. It is up to you to find the correct combination.

Comments (2)

c++ starstarstarstarstar   Posted by: sabbir on Wednesday, January 13, 2010

How does these std::methods work? starstarstarstarstar   Posted by: Cuckoo on Thursday, August 19, 2010

Just as the subject. For example, std::for_each is expend the loop?
for(int i = 0; i< 3:++i)
{
func(i);
}

is replace by
func(0);
func(1);
func(2);

but the complier prefer do that.

Add Your Rating

(Not published)
star
starstar
starstarstar
starstarstarstar
starstarstarstarstar
 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.