October 18th, 2006, 12:50 AM
Fun C++ Problem
This is not a homework assignment or anything.
A buddy of mine who works for a software company in Michigan sent me this problem.
He said it was on their yearly technical tests that they give programmers.
I only could figure out two ways to do this... and that took me a LONG time.
As far as the third solution goes, I have no idea, and neither does my friend. I can give you the first two though later on.
And, according to my friend, he said his boss has been giving this problem yearly since about 1999, and no one has figured out all three ways to do it.
take the following code:
int i, n = 20;
for (i=0; i<n; i--)
cout << "x" << endl;
by changing only ONE character in the above code, meaning you cannot change 20 to 31, because you will have changed two characters, you can change 20 to 21, because you only changed the 0, do the following:
find 3 ways to make the above code print x 20 times (by changing only one character).
Good luck, this drove me nuts for a while!
Last edited by dcjr84; October 18th, 2006 at 01:18 AM.
Please rate my post if you felt it was helpful
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!