public void AList2MaxIRandomTest() { int[] mas = new int[] { 5, -2, 4 }; a.Init(mas); int res = a.MaxI(); int expectedRes = 0; Assert.AreEqual(expectedRes, res); }
private static void ChooseOperation(string operation) { int[] mas; int num = 0; switch (operation) { case "1": Console.WriteLine(list.Size()); break; case "2": list.Clear(); break; case "3": Console.WriteLine("Input array length:"); int n = Convert.ToInt16(Console.ReadLine()); mas = new int[n]; for (int i = 0; i < n; i++) { try { mas[i] = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.Init(mas); Console.WriteLine(list.Size()); break; case "4": mas = list.ToArray(); foreach (int a in mas) { Console.WriteLine(a.ToString()); } break; case "5": for (int i = 0; i < 1; i++) { try { num = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.AddStart(num); break; case "6": Console.WriteLine("Input number to add:"); for (int i = 0; i < 1; i++) { try { num = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.AddEnd(num); break; case "7": Console.WriteLine("Input number to add and the place it will be added to:"); mas = new int[2]; for (int i = 0; i < 2; i++) { try { mas[i] = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.AddPos(mas[1], mas[0]); break; case "8": list.DelStart(); break; case "9": list.DelEnd(); break; case "10": Console.WriteLine("Input the index of the number to delete:"); for (int i = 0; i < 1; i++) { try { num = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.DelPos(num); break; case "11": Console.WriteLine(list.Min().ToString()); break; case "12": Console.WriteLine(list.Max().ToString()); break; case "13": Console.WriteLine(list.MinI().ToString()); break; case "14": Console.WriteLine(list.MaxI().ToString()); break; case "15": list.Reverse(); break; case "16": list.HalfReverse(); break; case "17": Console.WriteLine("Input the index of the number to get:"); for (int i = 0; i < 1; i++) { try { num = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } Console.WriteLine(list.Get(num).ToString()); break; case "18": Console.WriteLine("Input the index of the number to set and the value:"); mas = new int[2]; for (int i = 0; i < 2; i++) { try { mas[i] = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.Set(mas[0], mas[1]); break; case "19": list.Sort(); break; } }