Sunday, December 6, 2015
Swap Two Integers without Temporary Variable
public static void DoSwaping(int a, int b) {
a=a+b;
b=a-b;
a=a-b;
System.out.println("a: "+a+"\nb: "+b);
}
public static void main(String[] args) {
DoSwaping(5, 9); // Example Input
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
UA-39217154-2
No comments:
Post a Comment