运行 ❯
获取你的
自己的
网站
×
更改方向
更改主题,深色/浅色
转到 Spaces
#include <iostream> using namespace std; void swapNums(int &x, int &y) { int z = x; x = y; y = z; } int main() { int firstNum = 10; int secondNum = 20; cout << "Before swap: " << "\n"; cout << firstNum << secondNum << "\n"; swapNums(firstNum, secondNum); cout << "After swap: " << "\n"; cout << firstNum << secondNum << "\n"; return 0; }
交换前
1020
交换后
2010