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

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

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

#include <iostream>
#include <utility>
using namespace std;

// write your code here......

int swap (int& m, int& n)
{
    int temp;
    temp = m;
    m = n;
    n = temp;
    return m, n;
}

int main() {

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

    // write your code here......
    swap(m, n);


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

    return 0;
}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务