Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////ВЫБОР ПРОЦЕССОВ
- //Console.WriteLine("Выбор процессов");
- //Random rnd = new Random();
- //Console.WriteLine("Введите кол-во процессов");
- //int kolvoprocessov = Convert.ToInt32(Console.ReadLine());
- //string[] processi = new string[kolvoprocessov + 1];
- //int[] nachalnoevrema = new int[kolvoprocessov + 1];
- //int[] konechnoevrema = new int[kolvoprocessov + 1];
- //for (int i = 1; i < kolvoprocessov + 1; i++)
- //{
- // Console.WriteLine("Введите имя процесса номер " + i);
- // processi[i] = Console.ReadLine();
- // Console.WriteLine("Введите начальное время процесса номер " + i);
- // nachalnoevrema[i] = Convert.ToInt32(Console.ReadLine());
- // Console.WriteLine("Введите конечное время процесса номер " + i);
- // konechnoevrema[i] = Convert.ToInt32(Console.ReadLine());
- //}
- //Sortirovka(processi, nachalnoevrema, konechnoevrema, 1, kolvoprocessov);
- //List<string> Finalprocessi = greedy_active_selector(nachalnoevrema, konechnoevrema, processi);
- //Console.WriteLine("Финальные процессы");
- //foreach (string q in Finalprocessi)
- //{
- // Console.WriteLine(q);
- //}
- //Console.ReadKey();
- public static List<string> greedy_active_selector(int[] s, int[] f, string[] processi)
- {
- int n = s.Length;
- List<string> A = new List<string>();
- int i = 1;
- A.Add(processi[i]);
- for(int m = 2; m <n; m++)
- {
- if (s[m] >= f[i])
- {
- A.Add(processi[m]);
- i = m;
- }
- }
- return A;
- }
- public static void Sortirovka(string[] a, int[] s, int[] f, int l, int r)
- {
- int i = l;
- int j = r;
- int x = f[(l + r) / 2];
- while (i <= j)
- {
- while (f[i] < x) i++;
- while (f[j] > x) j--;
- if (i <= j)
- {
- int t1 = f[i];
- int t2 = s[i];
- string t3 = a[i];
- f[i] = f[i + 1];
- s[i] = s[i + 1];
- a[i] = a[i + 1];
- f[i + 1] = t1;
- s[i + 1] = t2;
- a[i + 1] = t3;
- i++;
- j--;
- }
- }
- if (l < j) Sortirovka(a, s, f, l, j);
- if (i < r) Sortirovka(a, s, f, i, r);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement