/ Published in: ActionScript 3
Looking forward for the most optimized solution for the same
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ public function init():void{ var a:Number = 5; var b:Number = 6; // solution 2 : using xor a = a^b; // a = 1^2 = 1 b = a^b; // b = 1^2 = 1 a = a^b; // a = 1^1 = 1 txt.text ="\n XOR Method >>> a: "+a+" b: "+b; // solution 1 a=a+b; // a = 1+2 = 3 b=a-b; // b = a-b = 3-2 = 1 a=a-b; // a = 3-1 = 2 txt.text += "\n Solution 1 >>> a: "+a+" b: "+b; // solution 3 a=a*b; b=a/b; a=a/b; txt.text +="\n Solution 3 >>> a: "+a+" b: "+b; } ]]> </mx:Script> <mx:TextArea x="118" y="57" width="553" height="412" id="txt"/> </mx:Application>