参考链接: https://blog.csdn.net/congxing9333/article/details/109656695?spm=1001.2014.3001.5501
- 运行代码如下:
#include <iostream>
using namespace std;
void swap(int num1, int num2)
{
cout << "交换前:" << endl;
cout << "num1 = " << num1 << endl;
cout << "num2 = " << num2 << endl;
int temp = num1;
num1 = num2;
num2 = temp;
cout << "交换后:" << endl;
cout << "num1 = " << num1 << endl;
cout << "num2 = " << num2 << endl;
//return ; 当函数声明时候,不需要返回值,可以不写return
}
int main()
{
int a = 10;
int b = 20;
swap(a, b);
cout << "mian中的 a = " << a << endl;
cout << "mian中的 b = " << b << endl;
system("pause");
return 0;
}
- 控制台运行后出现如下乱码:
- 点击VS code 右下角 UTF-8 然后 点击 通过编码保存 Save with Encoding
- 然后再输入框中输入gb 选择GB 2312 或者 GBK 都可以
- 再次运行后就看到没有乱码了