public static RecursList <int> ForthTask(RecursList <int> t, int b) { var res = new RecursList <int>(); for (int i = 0; i < t.Length; i++) { if (t[i] < b) { res.Add(t[i]); } } for (int i = 0; i < t.Length; i++) { if (t[i] == b) { res.Add(t[i]); } } for (int i = 0; i < t.Length; i++) { if (t[i] > b) { res.Add(t[i]); } } return(res); }
public static void TenTask(RecursList <int> a) { if (a.Length <= 1) { return; } if (a.Length == 2) { if (a[0] > a[1]) { int temp = a[0]; a[0] = a[1]; a[1] = temp; } return; } int ind = part_sort(a); if (ind == 0) { var a2 = new RecursList <int>(); for (int i = ind + 1; i < a.Length; i++) { a2.Add(a[i]); } TenTask(a2); for (int i = ind + 1; i < a.Length; i++) { a[i] = a2[i - ind - 1]; } } else { var a1 = new RecursList <int>(); for (int i = 0; i < ind; i++) { a1.Add(a[i]); } var a2 = new RecursList <int>(); for (int i = ind + 1; i < a.Length; i++) { a2.Add(a[i]); } TenTask(a1); TenTask(a2); for (int i = ind + 1; i < a.Length; i++) { a[i] = a2[i - ind - 1]; } for (int i = 0; i < ind; i++) { a[i] = a1[i]; } } }
public static RecursList <int> SecondTask(RecursList <int> t) { var res = new RecursList <int>(); for (int i = 0; i < t.Length; i++) { if (t[i] % 2 == 0) { res.Add(t[i]); } } for (int i = 0; i < t.Length; i++) { if (t[i] % 2 != 0) { res.Add(t[i]); } } return(res); }
public static int NineTask(RecursList <int> a) { var t = new RecursList <int>(); for (int i = 0; i < a.Length; i++) { if (t.Find(a[i]) == -1) { t.Add(a[i]); } } //t.Print(); return(t.Length); }
static void Main(string[] args) { var t = new RecursList <int>(); var rnd = new Random(); for (int i = 1; i <= 10; i++) { t.Add(i); } //FirstTask(t); //t.Print(); //SecondTask(t).Print(); //Console.WriteLine(ThirdTask("({})[]")); // for task 4 RecursList <int> rl = new RecursList <int>(); for (int i = 0; i < 10; i++) { rl.Add(rnd.Next(100)); } var c = new CountTimeAndExport2EXCEL.CountTime(sort); CountTimeAndExport2EXCEL.FunWithExcel.Save(c.StartCount(), @"E:\ALG\lab2.1.xlsx"); /*rl.Print(); * sort(rl); * rl.Print();*/ //ForthTask(rl, 3).Print(); //FifthTask(t); //SeventhTask(t).Print(); //t.Print(); //sortSimple(rl); //rl.Print(); //Console.WriteLine(); //Console.WriteLine(EightTask(t, rl)); }