Most elegant way to change 0 to 1 and vice versa
i = (i == 0)?1:0
is one way, though I like @Jimmy's and @Yuval's versions better.
subtraction?
i = 1 - i;
i ^= 1;
XOR the value with 1. This gives you both ways (in case you need to flip 0 <--> 1
either way):
0 ^ 1 = 1
1 ^ 1 = 0