Advertisement
parad0xxxxx

LW4 asc/desc sort

Jan 24th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement