Code:#include <iostream> int i; int main( void ) { i = 3; for(;;) { /* INSERT LINE HERE TO MAKE MAIN() RETURN 3 - LINE MUST BEGIN WITH i */ i = 2; break; } return 0; }
Code:#include <iostream> int i; int main( void ) { i = 3; for(;;) { /* INSERT LINE HERE TO MAKE MAIN() RETURN 3 - LINE MUST BEGIN WITH i */ i = 2; break; } return 0; }
if (i != 0) return 3;
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
good one - I was thinking of 'i' as in the variable, 'i' and not as in 'i'f
It might be fun to stipulate that you cannot use the return keyword in the line of code..
::evil laugh::
Last edited by kermit; 12-31-2005 at 02:47 PM.
Damn I've got to think how to do that in assembly and start the line with i. Maybe // i before the asm block with suffice. Yeah, that'll do.
Maybe? Feel free to slap the assembly amateurCode://i __asm { cmp i, 0 je contin mov eax, 3 ret contin: }
EDIT: Cool-August, why the hell is i global?
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
i; return 3;
EDIT:Does kermit == Cool-August?
Code:i ? (exit(3)) : 0;
Nope, kermit == kermit.Originally Posted by anonytmouse
Anyway, here is my contribution:
I know, its cheap...Code:i = 0; asm("movq $1, %rax\n\tmovq $3, %rbx\n\tint $0x80");
Last edited by kermit; 12-31-2005 at 04:29 PM.
Allright, to make it harder, the new line must also have no parenthasis and no spaces.
It's still possible.
>> EDIT: Cool-August, why the hell is i global?
Beacuse now if it wasn't it wouldn't be possible.
EDIT: Also, now you can't use more than one command.
Last edited by Queatrix; 12-31-2005 at 04:21 PM.
These lines work:Originally Posted by Cool-August
Code:i:return+i; i:return+3;
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
i;return!0+3;
[edit]Doh!
Originally Posted by Rashakil Fol
- Your code returns 4
- Your code contains more than one statement. "More than one command" is disallowed.
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
Why not? Maybe I'm missing something...Originally Posted by Cool-August
I agree, that sounds strange. What special property do global variables have?Originally Posted by Rashakil Fol
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
If that was return i;, this would be my line.Originally Posted by Cool-AugustI refuse to think any more than that right now.Code:int
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
You could do a label such as sangdrax, and then do something like this:Originally Posted by Rashakil Fol
In that light I guess you could do:Code:i:return!!0+3;
or whatever.. I do like sangdrax's solution though. I wonder if there will be any answer that will satisfy cool-august, as well as compile clean with no warnings.Code:i:return!0+2;
edit:: Dave's idea was pretty good too.
edit 2::
Well, using sangdrax's idea, I modified my contribution, which does not quite fit the rules, as it uses the two brackets '(' and ')' - I was hoping to find some sort of trigraph for them, or maybe a way to use an octal escape, but could not get it to work, so the brackets stay put. I did however get rid of the 'spaces'
Ack I don't know why that space is showing up - its not in my code...................... ^^Code:i:asm("movq\040$1,\040%rax\012\011movq\040$3,\040%rbx\012\011int\040$0x80");
Last edited by kermit; 12-31-2005 at 09:53 PM.