ChameL1oN

Лаба4_1

Mar 24th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <locale>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. void swap(int *a, int *b)
  7. {
  8. int c;
  9. c = *a;
  10. *a = *b;
  11. *b = c;
  12. }
  13.  
  14. void Sort(int *a, int *b, int *c)
  15. {
  16. if (*b > *a) swap(a, b);
  17. if (*c > *a) swap(a, c);
  18. if (*c > *b) swap(b, c);
  19. }
  20.  
  21. int main(int argc, char* argv[])
  22. {
  23. int a1, a2, a3;
  24.  
  25. a1 = 22; a2 = -11; a3 = 11;
  26.  
  27. cout << a1 << " " << a2 << " " << a3 << endl;
  28.  
  29. Sort(&a1, &a2, &a3);
  30.  
  31. cout << a1 << " " << a2 << " " << a3 << endl;
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment