+ 3

How ans is 444

#include<iostream> using namespace std; #define MIN(a,b) a>b?b:a main() { int a=2,b=3,c; c=MIN(++a,++b); cout<<a<<b<<c; }

5th Sep 2017, 1:19 PM
SANGMESH PATIL
SANGMESH PATIL - avatar
3 odpowiedzi
+ 15
Interesting. When you "passed" ++a and ++b, the macro acts as: ++a > ++b ? ++b : ++a In the code, this will cause a to be incremented twice instead of once.
5th Sep 2017, 1:49 PM
Hatsy Rei
Hatsy Rei - avatar
+ 11
@yuri Tbh, if you want a comment from me, I'd say that the above example shows how macros should be avoided (instead of prefix/postfix operators).
5th Sep 2017, 2:56 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
the more I know about increments the more crazy I get. it seems to be on safe side, one should avoid increments as much as possible. C/C++ people can disagree, but it could be a reason why ++ is not in Python.
5th Sep 2017, 2:43 PM
yuri