To swap two variables without using a third variable, use exclusive or manipulation... a ^= b; b ^= a; a ^= b;
y is an unknown. For now, let's just call y an apple. 9+ apple +apple would be a 9 and 2 apples, right? So 9 plus y plus y is 9+ 2y. Without knowing the value of y, that is as far as you can go.
The concept of being able to swap numbers in an addition sum is called the commutative property of addition.
Think of 1+1 in a real life situation. If you have 1 apple, and a friend gives you another apple, you have 2 apples (1 apple+ 1 apple= 2 apples). If it a situation in maths....i.e., not a general thinking
Nothing it will be the same cause your just swapping them around put if connected a different situation
bubble_sort (int N, int *A) { int i; swap = 1; while (swap) { swap = 0; for (i=0; i<N-1; ++i) { if (A[i] > A[i+1]) { swap = 1; A[i] ^= A[i+1]; A[i+1] ^= A[i]; A[i] ^= A[i+1]; } } } }
void swap(int& a, int& b ) { a^=b^=a^=b; }
if you say apple plus apple...it's already two apples!
Apple II Plus was created in 1979.
Apple IIc Plus was created in 1988.
To swap two variables without using a third variable, use exclusive or manipulation... a ^= b; b ^= a; a ^= b;
Apple cheesecake.
void swap(int &x, int &y) { x ^= y ^= x; } - or - void swap(int &x, int &y) { int t = x; x = y; y = t; }
tree apple
wow apple+pie= apple pie
void swap (int &pa, int &pb) { *pa ^= *pb; *pb ^= *pa; *pa ^= *pb; }
You can swap two integers without temporary storage by bitwise exclusive-or'ing them in a specific sequence...a ^= b;b ^= a;a ^= b;