价格30万的维纳斯# Joke - 肚皮舞运动
c*2
1 楼
In C, we can swap two items like this:
void swap(int *a,int *b)
{
int t = *a ;
*a = *b;
*b = t;
}
Sometimes in interviews, people may want a fancy swap like this:
void swap2(int *a,int *b)
{
*a=*a+*b;
*b=*a-*b;
*a=*a-*b;
}
Can anybody figure out what's wrong with swap2()?
void swap(int *a,int *b)
{
int t = *a ;
*a = *b;
*b = t;
}
Sometimes in interviews, people may want a fancy swap like this:
void swap2(int *a,int *b)
{
*a=*a+*b;
*b=*a-*b;
*a=*a-*b;
}
Can anybody figure out what's wrong with swap2()?