document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include<iostream>
  2. #include <list>
  3. using namespace std;
  4.  
  5. bool compareDigit (int first, int second);
  6. bool smallEndian (int first, int second);
  7.  
  8. int main()
  9. {
  10. int nums;
  11. while(cin>>nums)
  12. {
  13. list<int> mylist;
  14. for(int i=0;i<nums;i++)
  15. {
  16. int num;
  17. cin>>num;
  18. mylist.push_back(num);
  19. }
  20. mylist.sort(smallEndian);
  21. mylist.sort(compareDigit);
  22.  
  23. list<int>::iterator it;
  24. for (it=mylist.begin(); it!=mylist.end(); ++it)
  25. {
  26. cout << " " << *it;
  27. }
  28. cout<<endl;
  29. }
  30.  
  31. }
  32.  
  33. bool compareDigit (int first, int second)
  34. {
  35. int firstDigit = first%10;
  36. int secondDigit = second%10;
  37. if (firstDigit<secondDigit) return true;
  38. else return false;
  39. }
  40.  
  41. bool smallEndian (int first, int second)
  42. {
  43. if (first>second) return true;
  44. else return false;
  45. }
');