We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 794eccd commit 9433006Copy full SHA for 9433006
snippets/cpp/math-and-numbers/swap-numbers.md
@@ -0,0 +1,19 @@
1
+---
2
+title: Swap numbers
3
+description: Swaps two numbers without using third variable
4
+author: Emosans
5
+tags: swap,numbers
6
7
+
8
+```cpp
9
+#include<tuple>
10
+std::tuple<int,int> swap(int num1,int num2){
11
+ num1=num1+num2;
12
+ num2=num1-num2;
13
+ num1=num1-num2;
14
+ return std::make_tuple(num1,num2);
15
+}
16
17
+// Usage
18
+auto swapped=swap(3,4); // Returns a tuple (access the values using std::get<0>(swapped)/std::get<1>(swapped))
19
+```
snippets/cpp/string-manipulation/string-int.md
0 commit comments