/doc/Dissertation/Evolution/08_Remove_dead_jumps.cs

http://github.com/icsharpcode/ILSpy · C# · 69 lines · 69 code · 0 blank · 0 comment · 13 complexity · 51edf08662d032e1597fe76903d68dc4 MD5 · raw file

  1. using System;
  2. abstract class QuickSortProgram
  3. {
  4. public static void Main(System.String[] args)
  5. {
  6. System.Int32[] V_0 = new int[((int)args.Length)];
  7. int i = 0;
  8. for (;;) {
  9. if (!(i < ((int)V_0.Length))) {
  10. break;
  11. }
  12. else {
  13. }
  14. V_0[i] = System.Int32.Parse(args[i]);
  15. i = (i + 1);
  16. }
  17. QuickSortProgram.QuickSort(V_0, 0, (((int)V_0.Length) - 1));
  18. int j = 0;
  19. for (;;) {
  20. if (!(j < ((int)V_0.Length))) {
  21. break;
  22. }
  23. else {
  24. }
  25. System.Console.Write(System.String.Concat((V_0[j]).ToString(), " "));
  26. j = (j + 1);
  27. }
  28. }
  29. public static void QuickSort(System.Int32[] array, int left, int right)
  30. {
  31. if (!(right <= left)) {
  32. int i = ((left + right) / 2);
  33. int j = QuickSortProgram.Partition(array, left, right, i);
  34. QuickSortProgram.QuickSort(array, left, (j - 1));
  35. QuickSortProgram.QuickSort(array, (j + 1), right);
  36. }
  37. else {
  38. }
  39. }
  40. private static int Partition(System.Int32[] array, int left, int right, int pivotIndex)
  41. {
  42. int i = array[pivotIndex];
  43. QuickSortProgram.Swap(array, pivotIndex, right);
  44. int j = left;
  45. int k = left;
  46. for (;;) {
  47. if (!(k < right)) {
  48. break;
  49. }
  50. else {
  51. }
  52. if (!(array[k] > i)) {
  53. QuickSortProgram.Swap(array, j, k);
  54. j = (j + 1);
  55. }
  56. else {
  57. }
  58. k = (k + 1);
  59. }
  60. QuickSortProgram.Swap(array, right, j);
  61. return j;
  62. }
  63. private static void Swap(System.Int32[] array, int index1, int index2)
  64. {
  65. int i = array[index1];
  66. array[index1] = array[index2];
  67. array[index2] = i;
  68. }
  69. }