Skip to content

Swap two values · ⁨交换两个值⁩

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 可以读取或写入它所指向的值。用一个临时变量,免得在复制一个值时丢失另一个。

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩