I would imagine maxx would be used inside the loop.
I would imagine maxx would be used inside the loop.
Dae.IQ = Dae.IQ - 20;Originally Posted by Thantos
I don't know what you mean. Of course its possible maxx was used inside the loop, but what does stating maxx != rt + tt every increment do? its not a condition, its a statement.. right?
Its not a condition, its just.. out there.. for what reason?Code:for(int i = 0; i++ < limit; ) { maxx != rt + tt; }
Sorry I cant see any reason for why its there, other than none.
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
You tell me where it states that the third part of the for loop has to have anything to do with the first two parts. Heck I remember some interesting for loops posted on this board by some very bored programmers.
I'm not saying the third part of the for loop has to have anything to do with the others. I am saying that the first part of the for loop only occurs once (creation), at the beginning, of the for loop, the second part is the condition that is checked if still 1 (true) at the end of each loop, and the third is something that you want to occur at the end of every loop. Now why would you want 'maxx != rt + tt' to occur at the end of every loop? its not attached to an if statement, so there would be no purpose to it.. right? wrong? thats what I'm wondering.Originally Posted by Thantos
Code:for(int i = 0; i++ < limit; maxx != rt + tt) { ... } is equal to: for(int i = 0; i++ < limit; ) { maxx != rt + tt; }Since its a condition it should be in the second part of the for loop, or be attached to an if statement:Code:for(int i = 0; i++ < limit; maxx != rt + tt) { ... } is equal to: for(int i = 0; ; maxx != rt + tt) { if(!(i++ < limit)) break; }
Code:for(int i = 0; i++ < limit; if(maxx != rt + tt) break) { ... } is equal to: for(int i = 0; i++ < limit; ) { if(maxx != rt + tt) break; }
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
Who knows why they did it, its probably just a mistake they made, but really who cares?
It's actually a GCCism. a <?= b means the same as a < b ? a : b. In english, assign the minimum of a and b to a. You see stuff like that a lot in Topcoder from people trying to squeeze every second of time in their solutions.
Last edited by SilentStrike; 09-25-2005 at 05:37 PM.
I only wondered because half the people said it was short for !, and the other half said it was y > x ? x : y. The way its placed it doesnt make sense to be a trigraph. I guess with SilentStrike's reply thats right, that makes sense now.Originally Posted by Thantos
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
> from people trying to squeeze every second of time in their solutions.
Gotta be a real moron to believe that the number of characters your program occupies has anything to do with the performance of the code.
Do they really believe that since a <?= b takes fewer characters than a < b ? a : b, that the compiler will generate fewer compare instructions or branch instructions?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Yes, you are correct; it is true that idiots exist. Either the programmer's an idiot, or the compiler creator is an idiot.Originally Posted by Salem
If there is some programmer or compiler creator here that I've just insulted, this thread should take an interesting turn :-)
Of course, these artifacts from nonstandardized days shouldn't be forcibly removed from compilers, so we're being a bit unfair.
Actually, I'd say these people are MUCH smarter than me, and probably a bit smarter than you. They are squeezing seconds off of coding time, not running time.Gotta be a real moron to believe that the number of characters your program occupies has anything to do with the performance of the code.
Take a look at this, for example [registration required].
http://www.topcoder.com/stat?c=probl...696&cr=8355516
The code is cryptic, but I don't think you nor I would solve the problem in 7 minutes.
I actually have found that using <?= and >?= makes my code more buggy, since I somtimes omit characters and then do assignments or other similiar dumb stuff.
How do you know maxx, rt, or tt aren't objects with the != and + operators overloaded for some reason? The maxx != rt + tt statement might actually do something useful, although I really can't find a good reason why he would do it with those operators (especially !=) since it isn't intuitive.Originally Posted by Dae
If I recall correctly, a for statement that looks like this:
is basically the same as:Code:for (initializing statement; condition; expression) statement
So really, the expression can be just about anything. Though usually used to increment the loop, here it could be used just to update the variable. Maybe rt and tt change during the loop, and the OP wants to make sure that maxx = rt + tt at the end of each cycle through the loop. If you wanted to produce all fibonacci numbers under n, you could use it:Code:initializing statment while (condition) {statement; expression;}
Code:#include <cstdlib> #include <iostream> using namespace std; int main() { int oldFibo = 0; int olderFibo = 0; int n = 100; for (int fibo = 1; fibo < n; fibo = oldFibo + olderFibo) { olderFibo = oldFibo; oldFibo = fibo; cout << fibo << endl; } system("pause"); return 0; }
There is a difference between tedious and difficult.
> They are squeezing seconds off of coding time, not running time.
Absolutely pathetic reason if you ask me.
The biggest cost in software is understanding what the other person wrote (or even your own code) months after the event when it doesn't work anymore or needs to be enhanced.
Ever looked at any of your old "smart" code and wondered what the hell you were thinking of at the time?
Every stupid little trick in the book which obfuscates the code in some way simply adds to the difficulty.
I suppose they still think the xor swap without a temp is a really neat idea.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
That would be a very good point, lol, a little too late.. but very good point.Originally Posted by Speedy5
However, you cant overload <?=, and that is what was in the code, and someone said it stands for !=, which is the only reason I used != in that code you quoted.
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
You're right, it can be anything - as I said. However the condition statement is automatically considered to operate like an if statement, while the expression part does not. Hence if the OP was trying to check if maxx != tt + rt, he would have to use an if statement around it in the expression - as I exampled. Without the if statement (as it is in the OP's code) it does not make sense to be the != operator, as we now know according to SilentStrike.Originally Posted by Decrypt
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101