SHARE
TWEET

LW4 asc/desc sort

parad0xxxxx Jan 24th, 2020 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5.  
  6. {
  7.     int num, digit, checker = 0, a = 0;
  8.  
  9.     cout << "Enter an interger: ";
  10.     cin >> num;
  11.  
  12.     do
  13.     {
  14.         digit = num % 10;
  15.  
  16.         if (digit < checker)
  17.             a = 1;
  18.  
  19.         checker = digit;
  20.         num = num / 10;
  21.  
  22.     } while (num != 0);
  23.  
  24.     if (a == 0)
  25.         cout << "The numerals are sorted in ascending order from right to left - nice =)\n\n";
  26.     else
  27.         cout << "The numerals are not sorted in ascending order from right to left - not nice at all =(\n\n";
  28.  
  29.     return 0;
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top