Computer Chess Club Archives


Search

Terms

Messages

Subject: A nice programming riddle!

Author: Omid David

Date: 17:14:15 07/02/02


How do you swap the value of two integers without using a temporary integer (and
do it in one command)?
For example if a=3, b=7, after that one_line_command the values will be a=7,
b=3.

Hint: Use bitwise operations.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.