您的位置:首页 > 其它

面向对象程序设计上机练习四(变量引用)

2016-09-22 20:30 183 查看


面向对象程序设计上机练习四(变量引用)

Time Limit: 1000MS Memory Limit: 65536KB


Problem Description

将变量的引用作为函数形参,实现2个int型数据交换。


Input

输入2个int型整数。


Output

输出2个整数交换前后的值。


Example Input

88 66



Example Output

88 66
66 88




Code realization

#include <iostream>

using namespace std;
void swap(int *a,int *b)
{
int c=*a;
*a=*b;
*b=c;
}
int main()
{
int a,b;
cin>>a>>b;
cout<<a<<" "<<b<<endl;
swap(&a,&b);
cout<<a<<" "<<b<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: