Advertisement
Prohause

Untitled

Jun 13th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace CustomComparator
  6. {
  7. public class MyComparer : IComparer<int>
  8. {
  9. public int Compare(int x, int y)
  10. {
  11. return x % 2 == y % 2 ? 0 : x % 2 == 0 ? -1 : 1;
  12. }
  13. }
  14.  
  15. public class StartUp
  16. {
  17. public static void Main(string[] args)
  18. {
  19. var numbers = Console.ReadLine().Split(new[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries)
  20. .Select(int.Parse).OrderBy(p=>p).ToArray();
  21.  
  22. Array.Sort(numbers,new MyComparer());
  23. Console.WriteLine(string.Join(" ",numbers));
  24. }
  25.  
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement