Advertisement
Guest User

naggers

a guest
May 24th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. using System;
  2.  
  3. namespace DAKIPracticum3
  4. {
  5. class MainClass
  6. {
  7. public static void Main(string[] args)
  8. {
  9. string[] input = Console.ReadLine().Split();
  10. int regels = Convert.ToInt32(input[0]);
  11. // int lijstlimiet = Convert.ToInt32(input[1]);
  12. Breuk[] breuklijst = new Breuk[regels];
  13.  
  14. for(int i = 0; i < regels; i++)
  15. {
  16. string[] inputbreuk = Console.ReadLine().Split();
  17. int tellertje = Convert.ToInt32(inputbreuk[0]);
  18. int noemertje = Convert.ToInt32(inputbreuk[1]);
  19. Breuk breukje = new Breuk(tellertje, noemertje);
  20. breuklijst[i] = breukje;
  21. }
  22.  
  23. Console.WriteLine(breuklijst[0]);
  24. }
  25.  
  26. public static void quicksort(int[] A, int left, int right)
  27. {
  28. if (left > right || left < 0 || right < 0) return;
  29.  
  30. int index = partition(A, left, right);
  31.  
  32. if (index != -1)
  33. {
  34. quicksort(A, left, index - 1);
  35. quicksort(A, index + 1, right);
  36. }
  37. }
  38.  
  39. private static int partition(int[] A, int left, int right)
  40. {
  41. if (left > right) return -1;
  42.  
  43. int end = left;
  44.  
  45. int pivot = A[right]; // choose last one to pivot, easy to code
  46. for (int i = left; i < right; i++)
  47. {
  48. if (A[i] < pivot)
  49. {
  50. swap(A, i, end);
  51. end++;
  52. }
  53. }
  54.  
  55. swap(A, end, right);
  56.  
  57. return end;
  58. }
  59.  
  60. private static void swap(int[] A, int left, int right)
  61. {
  62. int tmp = A[left];
  63. }
  64.  
  65. static void insertionsort(IComparable[] array)
  66. {
  67. int i, j;
  68.  
  69. for (i = 1; i < array.Length; i++)
  70. {
  71. IComparable value = array[i];
  72. j = i - 1;
  73.  
  74. while ((j >= 0) && (array[j].CompareTo(value) > 0))
  75. {
  76. array[j + 1] = array[j];
  77. j = j - 1;
  78. }
  79.  
  80. array[j + 1] = value;
  81.  
  82. }
  83.  
  84. }
  85. }
  86.  
  87. class Breuk : IComparable<Breuk>
  88. {
  89. int teller, noemer;
  90.  
  91. public Breuk(int t, int n)
  92. {
  93. teller = t;
  94. noemer = n;
  95. }
  96.  
  97. public int CompareTo(Breuk breuk)
  98. {
  99. return this.teller * breuk.noemer - breuk.teller * this.teller;
  100. }
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement