MCPcopy Create free account
hub / github.com/142vip/408CSFamily / swap

Function swap

code/ds/BubbleSort.cpp:26–33  ·  view source on GitHub ↗

* 加减法实现两个元素值互换 */

Source from the content-addressed store, hash-verified

24 * 加减法实现两个元素值互换
25 */
26void swap(int a, int b){
27 // 此时a为两值的和
28 a=a+b;
29 // 此时b的值为a
30 b=a-b
31 // 如何实现让a的值为b呢??此时a的值为b
32 a=a-b;
33}
34
35
36// 临时变量实现两个元素值的互换

Callers 1

BubbleSwapSortFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected