private void RandomArray() { Console.WriteLine("Введите размер массива"); int size = UpgradedConsole.GetInt(1); Program.RandomArray(size); Console.WriteLine("Готово!"); Console.ReadKey(); }
private void KeyboardArray() { Console.WriteLine("Введите размер массива"); int size = UpgradedConsole.GetInt(1); double[] array = new double[size]; Console.WriteLine("Вводите элементы массива"); for (int i = 0; i < size; i++) { array[i] = UpgradedConsole.GetDouble(); } Program.SetArray(array); Console.WriteLine("Готово"); Console.ReadKey(); }
static void Main(string[] args) { const string info = "Программа вычисляет (X1+X2+2Xn)(X2+X3+2*X(n-1))...(X(n-1)+Xn+2*X2)"; Console.WriteLine(info); int n; List <double> x = new List <double>(); Console.WriteLine("Введите N, то есть сколько будет элементов в Xn"); n = UpgradedConsole.GetInt(2); Console.WriteLine("Вводите элементы, ввод закоончится, как только вы введете все элементы"); for (int i = 0; i < n; i++) { x.Add(UpgradedConsole.GetDouble()); } Console.WriteLine("Результат: " + GetResSequence(x.ToArray())); Console.ReadKey(); }
static void Main(string[] args) { List <double> a = new List <double>(); //Последовательность a int n; //Количество элементов последовательности, которые необходимо добавить Console.WriteLine("Введите a1"); a.Add(UpgradedConsole.GetDouble()); Console.WriteLine("Введите a2"); a.Add(UpgradedConsole.GetDouble()); Console.WriteLine("Введите a3"); a.Add(UpgradedConsole.GetDouble()); Console.WriteLine("Введите N"); n = UpgradedConsole.GetInt(1); n += a.Count; //ставим номер элемента, по который необходимо найти последовательсть Console.WriteLine(); //Разделяем для красоты:) Console.Write($"Последовательность:\n{a[0]}; {a[1]}; {a[2]}"); for (int i = 3; i < n; i++) { a.Add((a[i - 1] + a[i - 2]) / 2 - a[i - 3]); Console.Write($"; {a[i]}"); } Console.WriteLine(); Console.WriteLine(); //Разделяем для красоты:) List <double> res = MaxIncrementingSubsequence(a); //Получаем максимальную подпоследовательность Console.WriteLine("Длина максимальной подпоследовательности: " + res.Count + "\n"); Console.WriteLine("Последний элемент подпоследовательности: " + res[res.Count - 1] + "\n"); Console.WriteLine("Максимальная подпоследовательность:"); Console.Write(res[0]); for (int i = 1; i < res.Count; i++) { Console.Write("; " + res[i]); } Console.ReadKey(); }
static void AddItem(MyListInt myList) { Console.WriteLine("Введите число, которое необходимо добавить"); myList.Add(UpgradedConsole.GetInt()); }
public void ChangeShift() { Console.WriteLine("Введите новый сдвиг"); Program.Shift = UpgradedConsole.GetInt(); }