指针变量
#include<iostream> using namespace std; void compare(int a,int b){ int rand; if(a<b){ rand=a; a=b; b=rand; } cout<<a<<' '<<b; } int main(){ int x,y; cin>>x>>y; compare(x,y); }
#include<iostream> using namespace std; int main(){ int x,y,*a,*b,*p; cin>>x>>y; a=&x; b=&y; if(x<y){ p=a; a=b; b=p; } cout<<"max="<<*a<<"min="<<*b; }