2023/4/22

交换两个整数次序

 

#include<iostream>
using namespace std;
void swap(int &a,int &b)
{
int t=a;
a=b;
b=t;
}
int main()
{
int x=5,y=10;
cout<<"x="<<x<<" y="<<y<<endl;
swap(x,y);
cout<<"x="<<x<<" y="<<y<<endl;
return 0;
}

posted on 2023-04-22 23:37  清荣峻茂  阅读(20)  评论(0)    收藏  举报