跟风发个这种蛋疼文体。
普通程序员
void swap(int &a,int &b)
{
int temp;
temp=a;
a=b;
b=temp;
void swap(int &a,int &b)
{
a=a^b;
b=a^b;
a=a^b;
void swap(int a,int b)
{
int temp;
temp=a;
a=b;
b=temp;
}
普通程序员
void swap(int &a,int &b)
{
int temp;
temp=a;
a=b;
b=temp;
}
void swap(int &a,int &b)
{
a=a^b;
b=a^b;
a=a^b;
}
void swap(int a,int b)
{
int temp;
temp=a;
a=b;
b=temp;
}
希望能引起广大苦逼的正在学或者已经学过c++人的共鸣和会心一笑吧。。
本文展示了三种不同风格的变量交换代码实现:普通版、文艺版及2B版。普通版采用临时变量进行交换;文艺版使用异或操作实现无临时变量交换;2B版错误地将参数作为值传递而非引用。
9610

被折叠的 条评论
为什么被折叠?



