由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - What is the methology to solve problems like swapping variables?
相关主题
[合集] some file operation questionsambiguous operators in c++
Effective C++ 这破书!问个函数指针指向操作符的问题
C++ operator = overloading用copy & swap有啥优点C语言里面的register变量能否进行取地址操作? (转载)
register variable[C++] 入门级问题 increment and decrement operators
C++ Q87: What is wrong with this swap function? (转载)why copy assignment operator returns non-const type?
lambda的一个疑问Scala的operator似乎不太好读
请教算法题mxnet/tf的一个比较blog
sql 数据是存在哪里 (转载)你们ee读一个master by course要五年吗?
相关话题的讨论汇总
话题: operations话题: what话题: methology话题: variables话题: solve
进入Programming版参与讨论
1 (共1页)
k******r
发帖数: 2300
1
For example, if we want to use bit operations to swap two variables without
using temporary variable. Any one can tell me how to develop an approach to
using bit operations to solve such problems step by step. Because the bit
operations usually don't look intuitive so the thread of thoughts behind that
is very important in mastering bit operations. Thanks so much for your
tutorial.
r******p
发帖数: 9
2
a ^= b;
b ^= a;
a ^= b;

that

【在 k******r 的大作中提到】
: For example, if we want to use bit operations to swap two variables without
: using temporary variable. Any one can tell me how to develop an approach to
: using bit operations to solve such problems step by step. Because the bit
: operations usually don't look intuitive so the thread of thoughts behind that
: is very important in mastering bit operations. Thanks so much for your
: tutorial.

k******r
发帖数: 2300
3
Can you tell me how you get it? I guess it is more important than the answer.

【在 r******p 的大作中提到】
: a ^= b;
: b ^= a;
: a ^= b;
:
: that

r******p
发帖数: 9
4
(a^b)^b = a, with reflexivity

.

【在 k******r 的大作中提到】
: Can you tell me how you get it? I guess it is more important than the answer.
l***t
发帖数: 81
5
Actually, it is associativity for ^:
(a^b)^b = a^(b^b) = a^0 = a

【在 r******p 的大作中提到】
: (a^b)^b = a, with reflexivity
:
: .

r******p
发帖数: 9
6
以前有人贴过一个特全面介绍的link,找不到了

【在 l***t 的大作中提到】
: Actually, it is associativity for ^:
: (a^b)^b = a^(b^b) = a^0 = a

1 (共1页)
进入Programming版参与讨论
相关主题
你们ee读一个master by course要五年吗?C++ Q87: What is wrong with this swap function? (转载)
Re: can destructor be static?lambda的一个疑问
matlab: find main workspace variable?请教算法题
what's wrong with this scripts?variable passing?sql 数据是存在哪里 (转载)
[合集] some file operation questionsambiguous operators in c++
Effective C++ 这破书!问个函数指针指向操作符的问题
C++ operator = overloading用copy & swap有啥优点C语言里面的register变量能否进行取地址操作? (转载)
register variable[C++] 入门级问题 increment and decrement operators
相关话题的讨论汇总
话题: operations话题: what话题: methology话题: variables话题: solve