Advertisement
filomancio

Ordinamento 3 numeri con riferimento

Feb 28th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include "iostream"
  2.  
  3. void OrdinaRiferimento (int& a, int& b, int& c);
  4.  
  5. using namespace std;
  6. int main()
  7. {
  8.     int a=8,b=4,c=10;
  9.     OrdinaRiferimento (a,b,c);
  10.     cout<<a<<' '<<b<<' '<<c<<endl;
  11.     system("PAUSE");
  12.     return 0;
  13. }
  14.  
  15. void OrdinaRiferimento(int& a, int& b, int& c)
  16. {
  17.     int temp;
  18.     if (a>b)
  19.     {
  20.         temp=a;
  21.         a=b;
  22.         b=temp;
  23.     }
  24.     if (a>c)
  25.     {
  26.         temp=a;
  27.         a=c;
  28.         c=temp;
  29.     }
  30.     if (b>c)
  31.     {
  32.         temp=b;
  33.         b=c;
  34.         c=temp;
  35.     }    
  36.     return;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement