1 #include<iostream> 2 using namespace std; 3 void compare(int a,int b){ 4 int rand; 5 if(a<b){ 6 rand=a; 7 a=b; 8 b=rand; 9 } 10 cout<<a<<' '<<b; 11 } 12 int main(){ 13 int x,y; 14 cin>>x>>y; 15 compare(x,y); 16 }
#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; }