+ 1
Swap two variable values without using a third variable
... and no functions either!
10 odpowiedzi
+ 8
a=a+b-(b=a);
+ 5
Or this:
a=a+b;
b=a-b;
a=a-b;
+ 4
before u get misleaded by other comments -best answer is from riisu.
filip 's answer is correct too but riisu's one is faster and neetish doesnt know a **** about programming
+ 4
Why was it wrong?
+ 4
😂😂😂
+ 3
if(&x!=&y){
x ^= y;
y ^= x;
x ^= y;
}
+ 1
no bro sorry its right😂😂😂 sorry
+ 1
__asm
{
mov eax, Var1
xchg eax, Var2
xchg eax, Var1
}
Didn't say we couldn't use assembly :p
0
😂😂😂😂 filip ur first answer was wrong.😂😂😂😂
- 6
int a =3
int b=4
a=b-1
b=a