Advertisement
fannyfan414

Untitled

Apr 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. /////////////////////ВЫБОР ПРОЦЕССОВ
  2. //Console.WriteLine("Выбор процессов");
  3. //Random rnd = new Random();
  4. //Console.WriteLine("Введите кол-во процессов");
  5. //int kolvoprocessov = Convert.ToInt32(Console.ReadLine());
  6. //string[] processi = new string[kolvoprocessov + 1];
  7. //int[] nachalnoevrema = new int[kolvoprocessov + 1];
  8. //int[] konechnoevrema = new int[kolvoprocessov + 1];
  9. //for (int i = 1; i < kolvoprocessov + 1; i++)
  10. //{
  11. // Console.WriteLine("Введите имя процесса номер " + i);
  12. // processi[i] = Console.ReadLine();
  13. // Console.WriteLine("Введите начальное время процесса номер " + i);
  14. // nachalnoevrema[i] = Convert.ToInt32(Console.ReadLine());
  15. // Console.WriteLine("Введите конечное время процесса номер " + i);
  16. // konechnoevrema[i] = Convert.ToInt32(Console.ReadLine());
  17. //}
  18.  
  19.  
  20. //Sortirovka(processi, nachalnoevrema, konechnoevrema, 1, kolvoprocessov);
  21.  
  22.  
  23.  
  24. //List<string> Finalprocessi = greedy_active_selector(nachalnoevrema, konechnoevrema, processi);
  25. //Console.WriteLine("Финальные процессы");
  26. //foreach (string q in Finalprocessi)
  27. //{
  28. // Console.WriteLine(q);
  29. //}
  30. //Console.ReadKey();
  31. public static List<string> greedy_active_selector(int[] s, int[] f, string[] processi)
  32. {
  33. int n = s.Length;
  34. List<string> A = new List<string>();
  35. int i = 1;
  36. A.Add(processi[i]);
  37.  
  38. for(int m = 2; m <n; m++)
  39. {
  40. if (s[m] >= f[i])
  41. {
  42. A.Add(processi[m]);
  43. i = m;
  44. }
  45. }
  46. return A;
  47. }
  48.  
  49. public static void Sortirovka(string[] a, int[] s, int[] f, int l, int r)
  50. {
  51. int i = l;
  52. int j = r;
  53. int x = f[(l + r) / 2];
  54. while (i <= j)
  55. {
  56. while (f[i] < x) i++;
  57. while (f[j] > x) j--;
  58. if (i <= j)
  59. {
  60. int t1 = f[i];
  61. int t2 = s[i];
  62. string t3 = a[i];
  63.  
  64. f[i] = f[i + 1];
  65. s[i] = s[i + 1];
  66. a[i] = a[i + 1];
  67. f[i + 1] = t1;
  68. s[i + 1] = t2;
  69. a[i + 1] = t3;
  70. i++;
  71. j--;
  72.  
  73. }
  74. }
  75. if (l < j) Sortirovka(a, s, f, l, j);
  76. if (i < r) Sortirovka(a, s, f, i, r);
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement