- With temp variable
public void swap(int a,int b)
{
int temp=a;
a=b;
b=temp;
}
- Without temp variable
public void swap(int a,int b)
{
a=a+b;
b=a-b;
a=a-b;
}
No comments:
Post a Comment