1 solutions

  • 2
    @ 2024-3-22 15:11:31
    //可以通过传引用的方式,将改变以后的值返回到主函数之中
    #include<bits/stdc++.h>
    using namespace std;
    void change(int &x,int &y)
    {
    	int t=x;
    	x=y;
    	y=t;
    }
    int main()
    {
    	int a,b;
    	cin>>a>>b;
    	change(a,b);
    	cout<<a<<" "<<b;
    	return 0;
    }
    
    
    • 1

    Information

    ID
    110
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    (None)
    # Submissions
    29
    Accepted
    20
    Uploaded By