您的位置:首页 > 其它

初学指针(输入两个整数,由大到小输出)

2017-12-08 09:32 169 查看
#include <iostream>
using namespace std;
int main()
{
void Swap(int *p1,int *p2);
int a,b;
cout<<"please enter a and b"<<endl;
cin>>a>>b;
int *pointer_1=&a,*pointer_2=&b;
if(a<b)
Swap(pointer_1,pointer_2);
cout<<a<<b<<endl;// cout<<"a="<<" "<<a<<endl<<"b="<<" "<<b<<endl;
return 0;
}
void Swap(int *p1,int *p2)
{
int tmp=*p1;
*p1=*p2;
*p2=tmp;
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐