题解 | #编写函数实现两数交换(引用方式)#

编写函数实现两数交换(引用方式)

https://www.nowcoder.com/practice/19ff3da82df740a9a662aaf59aa41c5d

#include <iostream>
using namespace std;

// write your code here......
void swapx(int &p,int &q)
{
    int tmp;
    tmp=p;
    p=q;
    q=tmp;


}

int main() {

    int m, n;
    cin >> m;
    cin >> n;

    // write your code here......
    int &p=m;
    int &q=n;
    swapx(p, q);

    cout << m << " " << n << endl;

    return 0;
}

全部评论

相关推荐

牛客96763241...:这个简历和我的模板一样,左面太空了,不协调,自己调一下会更好
点赞 评论 收藏
分享
01-30 09:45
燕山大学 Java
喵_coding:这种直接跑就完事了 哪有毕业了才签合同 任何offer和三方都没有的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务