Tuesday, February 16, 2010

Programmer - C++ Challenge: Creating a prefixed sequence in one line

Programmer Question

Hello, I was optimizing my program code and needed exactly to do that. Delete this, if you think this is not a real question, because I already know how to do it, but I am curious about your answers since I already asked all of my colleagues about their solutions.



Given the initialized variables unsigned a, unsigned b with b > a and std::vector<std::string> strings of size b-a. How can I fill strings with the elements e.g. "x3" "x4" "x5" "x6" (in case a=3 and b=7) for arbitrary a and b with one C++ command (meaning one semicolon at all :)). Note: I used the Boost libraries for it.

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails