Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Delphi-News aus aller Welt (https://www.delphipraxis.net/58-delphi-news-aus-aller-welt/)
-   -   Swap two integers without using a temporary variable (https://www.delphipraxis.net/208941-swap-two-integers-without-using-temporary-variable.html)

DP News-Robot 2. Okt 2021 15:20

Swap two integers without using a temporary variable
 
Here's a clever little algorithm you can use to swap two integers without using a temporary variable.

I rediscovered this tip, by Muhammad Saied, while reviewing my Delphi Tips micro-site.

Dunno why, but I find this strangley pleasing!

Assume we have two integers, A & B, both of which have values assigned. Swap their values like this:

<div style="text-align: left;">


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:08 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz