Return to Snippet

Revision: 63600
at May 21, 2013 16:35 by zaxbbun


Updated Code
// solution one
//
template <class T>
void swap(T *a, T *b){
    *a = *a + *b;
    *b = *a - *b;
    *a = *a - *b;
}


// solution two
//
template <class T>
void swap(T &a, T &b){
    a = a * b;
    b = a / b;
    a = a / b;
}

Revision: 63599
at May 21, 2013 16:26 by zaxbbun


Initial Code
template <class T>
void swap(T *a, T *b){
    *a = *a + *b;
    *b = *a - *b;
    *a = *a - *b;
}

Initial URL


Initial Description
swap: swap two numbers without using the third object( or variable)

Initial Title
swap: swap two numbers without using a third object( or variable)

Initial Tags


Initial Language
C