LFPS - Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Swapping without using a third variable

2 posters

Go down

Swapping without using a third variable Empty Swapping without using a third variable

Post by shirish.vogga 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
shirish.vogga
shirish.vogga
New LSF Member
New LSF Member

Posts : 3

Back to top Go down

Swapping without using a third variable Empty Re: Swapping without using a third variable

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

Please use the Code tags for your source codes

[code]
Sujith
Sujith
LSF Expert
LSF Expert

Posts : 126

http://osalfps.org

Back to top Go down

Back to top

- Similar topics

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