Al Salam Alikom
I have 2 integers x&y .
I Want to Swap thos values .
this Code is works very good :
كود:temp = x; x = y; y = temp ;
Now you have to do this Operation without Using the temp var ,
Al Salam Alikom
I have 2 integers x&y .
I Want to Swap thos values .
this Code is works very good :
كود:temp = x; x = y; y = temp ;
Now you have to do this Operation without Using the temp var ,
GAWD, are you _itching_ for the old XOR trick? can I cheat and use implicit temporaries in function arguments?
كود:int x, y; void swap (int a, int b) { x = b; y = a; } [initialize x and y here] swap (x, y);
are you Keding man ?المشاركة الأصلية كتبت بواسطة ibn_alqalam
.
1- Calling the function swap() is creating 2 Vars in the Memory, so it dosn't work.
2- you cn do it with XOR func , but there is another Easy way .
Just think![]()