+ 5

Challenge :In how many ways you can swap two values?

eg. If x=2 and y=3 then after swaping x becomes 3 and y becomes 2

18th Sep 2017, 3:18 PM
subham sahu
subham sahu - avatar
7 Respuestas
+ 11
m1 ) int x=2,y=3; x=x+y; y=x-y; x=x-y; m2) int x=2,y=3,t=0; t=x; x=y; y=t; m3) int x=2,y=3; if (x !=0 && y !=0) x *=y; y=x/y; x=x/y; m4) ... u can make infinite methods 😂..😅
18th Sep 2017, 3:29 PM
Changed
Changed - avatar
+ 3
https://code.sololearn.com/cjwyyo9RkDGL/?ref=app Well i believe i've done what the challenge requires
18th Sep 2017, 4:26 PM
Ghostware
Ghostware - avatar
+ 3
wow I am getting new ideas
19th Sep 2017, 1:00 AM
subham sahu
subham sahu - avatar
+ 2
very good
18th Sep 2017, 3:41 PM
subham sahu
subham sahu - avatar
+ 2
it's good
19th Sep 2017, 11:47 PM
subham sahu
subham sahu - avatar
22nd Sep 2017, 9:25 AM
subham sahu
subham sahu - avatar
+ 1
in python x=4 y=5 x , y = y , x
18th Sep 2017, 4:11 PM
sayan chandra
sayan chandra - avatar