Swapping without using a third variable

View previous topic View next topic Go down

Swapping without using a third variable

Post by shirish.vogga on Sat Aug 14, 2010 9:00 pm

Code:

class Swa_p
{
    public static void main(String[] args)
    {
        int a=Integer.parseInt(args[0]);
        int b=Integer.parseInt(args[1]);
        a=a+b; //a=6//
        b=a-b; //b=2//
        a=a-b; //a=4//
        System.out.println(a);
        System.out.println(b);
    }
}

Code:

E:\Program Files\Java\jdk1.6.0\bin>java Swa_p 12 13
13
12
avatar
shirish.vogga
New LSF Member
New LSF Member

Posts : 3

Back to top Go down

Re: Swapping without using a third variable

Post by Sujith on Sun Aug 15, 2010 6:16 am

Please use the Code tags for your source codes

[code]

______________________________________________________
It is the simplest things that are most Complicated!
Been on this forum since 2695 days!

avatar
Sujith
LSF Expert
LSF Expert

Posts : 126

http://osalfps.org

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum