运用swap函数实现两个数交换
#include
using namespace std;
void Swap(int *x,int *y){
int temp= *x;
*x= *y;
*y=temp;
}
int main(){
int a,b;
cin>>a>>b;
Swap(&a,&b);
cout&lt;<a>&lt;&lt;&quot; &quot;&lt;</a>
#include
using namespace std;
void Swap(int *x,int *y){
int temp= *x;
*x= *y;
*y=temp;
}
int main(){
int a,b;
cin&gt;&gt;a&gt;&gt;b;
Swap(&amp;a,&amp;b);
cout&lt;<a>&lt;&lt;&quot; &quot;&lt;</a>
全部评论
相关推荐
点赞 评论 收藏
分享
06-30 15:54
湖北文理学院 Java 点赞 评论 收藏
分享

点赞 评论 收藏
分享