Swap two values · 交换两个值
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
Swap two values
swap receives pointers to two integers and must exchange their values. Through a pointer, *a reads — or writes — the value it points at. Use a temporary variable so you don't lose one value while copying the other.
中文
交换两个值
swap 接收指向两个整数的指针,必须交换它们的值。通过指针,*a 可以读取或写入它所指向的值。用一个临时变量,免得在复制一个值时丢失另一个。
Complete void swap(int *a, int *b) to exchange the two integers that a and b point to. Use the pointers — *a is the value at a. · 完成 void swap(int *a, int *b),交换 a 和 b 指向的两个整数。使用指针 —— *a 是 a 处的值。
Click Run to see the output here. · 点击“运行”查看此处输出。