Swap two values · สลับสองค่า
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 รับ pointers ของจำนวนเต็มสองตัวและต้องแลกเปลี่ยนค่าของพวกเขา ผ่าน pointer, *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. · คลิก Run เพื่อดูผลลัพธ์ที่นี่