-
November 18th, 2011, 04:36 PM
#61
Re: Fun C++ Problem
Originally Posted by VladimirF
If n is -20, i=0 will never be less than n.
Interestingly, since I didn’t want to read past the first few posts, I did not realize that I played this game five years ago, and accidentally found (again) all three solutions. Again without timing; about 10 minutes, I guess.
Do I get a double bonus?
i is DEcremented, not INcremented. So i will= -1, -2, -3...etc until it passes -20.
-
November 19th, 2011, 03:00 AM
#62
Re: Fun C++ Problem
Originally Posted by whitevandal
i is DEcremented, not INcremented. So i will= -1, -2, -3...etc until it passes -20.
Right, but if n = -20
Then i < n will fail as 0 < -20 evaluates to false. Thus i will actually just equal 0, and "x" will be printing 0 times.
-
November 26th, 2012, 08:06 PM
#63
Re: Fun C++ Problem
There are four so far... anyone want to see them
for (i=0; i+n; i--)
for (i=0; i<n; n--)
for (i=0;-i<n; i--)
for (i=0;~i<n; i--)
Neat question, not a very good introduction. Once someone finds three, they think they are a genius. Did someone find another?
By the way, the unary NOT is replacing a space (" ") just like the negative symbol
-
November 26th, 2012, 08:13 PM
#64
Re: Fun C++ Problem
My bad, dumb, should've read the posts about the unary operator. Silly oversight, great problem for the class.
-
November 27th, 2012, 11:51 AM
#65
Re: Fun C++ Problem
What's wrong with this one?
for (i=40; i<n; i--)
-
November 27th, 2012, 06:40 PM
#66
Re: Fun C++ Problem
Originally Posted by shavarsh
What's wrong with this one?
for (i=40; i<n; i--)
This is a character insertion and as such it's against the rules which only allow changing existing characters.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
November 28th, 2012, 07:02 AM
#67
Re: Fun C++ Problem
I'm not trying to be a smart ***, but this is not insertion?
for (i=0;-i<n; i--)
Or in this case, we substitute default-hidden '+' ?
-
November 28th, 2012, 08:25 AM
#68
Re: Fun C++ Problem
Originally Posted by shavarsh
I'm not trying to be a smart ***, but this is not insertion?
for (i=0;-i<n; i--)
The original code has a space character where the minus sign now is - so it is replacing the space.
-
June 18th, 2013, 08:54 PM
#69
Re: Fun C++ Problem
Don't mean to show off but it took maybe 20 seconds. I can't imagine no one has got that on his quiz or whatever since 1999 that's absurd.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|