Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7.7 指针和函数 输出最好修改一下哟 #3

Open
xiaoerjason opened this issue Dec 30, 2021 · 0 comments
Open

7.7 指针和函数 输出最好修改一下哟 #3

xiaoerjason opened this issue Dec 30, 2021 · 0 comments

Comments

@xiaoerjason
Copy link

`int main() {

int a = 10;
int b = 20;
swap1(a, b); // 值传递不会改变实参

swap2(&a, &b); //地址传递会改变实参

cout << "a = " << a << endl;

cout << "b = " << b << endl;

system("pause");

return 0;

}修改成这样子会不会更好点呢?int main() {

int a = 10;
int b = 20;
swap1(a, b); // 值传递不会改变实参

cout << "swap1 a = " << a << endl;

cout << "swap1 b = " << b << endl;

swap2(&a, &b); //地址传递会改变实参

cout << "swap2 a = " << a << endl;

cout << "swap2 b = " << b << endl;

system("pause");

return 0;

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant