Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream> //for cin >> and cout <<
  2. #include <string>
  3. #include <iomanip>
  4. #include <Windows.h>
  5. using namespace std;
  6.  
  7. int main(){
  8.     void swap(int&, int&);
  9.     int x;
  10.     int y;
  11.     cout << "Enter values to be sorted: ";
  12.     cin >> x >> y;
  13. /*
  14.     cout << "Values before sorting:" ;
  15. */
  16.     if (x > y)
  17.         swap(x, y);
  18.     cout << "Values in ascending order: " << x <<", "<< y <<"\n";
  19.         system("pause");
  20.         return(0);
  21. }
  22.  
  23. void swap (int& a, int& b)
  24. {
  25.     while (a > b)
  26.     {
  27.         int temp;
  28.         temp = a;
  29.         a = b;
  30.         b = temp;
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement