static void Main(string[] args) { do { Random rand = new Random(); // Создаём отдельную последовательность. GeometricProgression FirstProgression = new GeometricProgression(rand.NextDouble() * 10, rand.NextDouble() * 5); WriteLine("Отдельная посл-ть:\n" + FirstProgression.GetInfo()); // Создаём массив прогрессий. GeometricProgression[] Progs = new GeometricProgression[rand.Next(5, 16)]; for (int i = 0; i < Progs.Length; ++i) { Progs[i] = new GeometricProgression(rand.NextDouble() * 10, rand.NextDouble() * 5); WriteLine("Посл-ть №" + (int)(i + 1) + " :\n" + Progs[i].GetInfo()); } WriteLine(); int step = rand.Next(3, 16); for (int i = 0; i < Progs.Length; ++i) { if (Progs[i][step] > FirstProgression[step]) { WriteLine("У посл-ти №" + (int)(i + 1) + " значение эл-та " + step + " больше, чем у отдельной. :\n" + Progs[i].GetInfo()); } WriteLine("У посл-ти №" + (int)(i + 1) + " сумма первых " + step + " эл-тов равна " + Progs[i].GetSum(step)); } WriteLine("Чтобы завершить выполнение программы, введите пустую строку."); WriteLine("Введите что угодно, чтобы перезапустить процесс."); }while (ReadLine() != ""); }
static void Main(string[] args) { do { Console.Clear(); GeometricProgression b = new GeometricProgression(rnd.Next(0, 10), rnd.Next(0, 1)); GeometricProgression[] arr = new GeometricProgression[rnd.Next(5, 16)]; for (int i = 0; i < arr.Length; i++) { arr[i] = new GeometricProgression(rnd.Next(0, 10), rnd.Next(2, 6)); } int step = rnd.Next(3, 16); Console.WriteLine($"\n\tStep = {step}\tb[step] = {b[step]}\n"); for (int i = 0; i < arr.Length; i++) { if (arr[i][step] > b[step]) { Console.WriteLine(arr[i].ToString() + $"\tarr[i][step] = {arr[i][step]}"); } } Console.WriteLine($"\n\tSum of Progression of array for step = {step} elements\n"); for (int i = 0; i < arr.Length; i++) { Console.WriteLine(arr[i].ToString() + $"\tSum of {step} elements = {arr[i].GetSum(step):f3}"); } } while (Console.ReadKey().Key != ConsoleKey.Escape); }
static void Main(string[] args) { do { Console.Clear(); GeometricProgression prog = new GeometricProgression(); Random rnd = new Random(); GeometricProgression[] progArray = new GeometricProgression[rnd.Next(5, 16)]; for (int i = 0; i < progArray.Length; i++) { progArray[i] = new GeometricProgression(rnd.Next(0, 10) + rnd.NextDouble(), rnd.Next(1, 5) + rnd.NextDouble()); } int step = rnd.Next(3, 16); Console.WriteLine("\nИнформация о всех прогрессиях:"); Array.ForEach(progArray, y => Console.WriteLine(y.ToString())); Console.WriteLine("Уникальная:" + prog.ToString()); Console.WriteLine("\nВсе последовательности из массива, у которых элемент с номером step больше, чем у отдельной последовательности:"); Array.ForEach(Array.FindAll(progArray, x => x[step] > prog[step]), y => Console.WriteLine(y.ToString())); Console.WriteLine("\nВыводим сумму первых step членов"); Array.ForEach(progArray, x => Console.WriteLine(x.ToString() + $"\tСумма: {x.GetSum(step):f2}")); Console.WriteLine("\nНажмите Escape, если хоитте выйти\nИли любую другую клавишу, если хотите продолжить"); } while (Console.ReadKey().Key != ConsoleKey.Escape); }
static void Main(string[] args) { Random rnd = new Random(); GeometricProgression g_p = new GeometricProgression(rnd.NextDouble() * 10, 5 - 5 * rnd.NextDouble()); Console.WriteLine(g_p.GetInfo()); int n = int.Parse(Console.ReadLine()); GeometricProgression[] progressions = new GeometricProgression[n]; for (int i = 0; i < n; ++i) { progressions[i] = new GeometricProgression(rnd.NextDouble() * 10, 5 - 5 * rnd.NextDouble()); Console.WriteLine(progressions[i].GetInfo()); } int step = rnd.Next(3, 16); Console.WriteLine($"{step}-ый элемент последовательности больше, чем в последовательности ({g_p.GetInfo()}):"); for (int i = 0; i < n; ++i) { if (progressions[i][step] > g_p[step]) { Console.WriteLine(progressions[i].GetInfo()); } } }
static void Main(string[] args) { while (true) { int n = new Random().Next(5, 16); GeometricProgression geometric = new GeometricProgression(new Random().NextDouble() * 10, new Random().NextDouble() * (5 - 0.0001) + 0.0001); Console.WriteLine("Главная последовательность: "); Console.WriteLine(geometric.ToString()); Console.WriteLine(); int step = new Random().Next(3, 16); GeometricProgression[] arr = new GeometricProgression[n]; Console.WriteLine($"У этих последовательностей элемент с номером {step} больше чем у главной: "); for (int i = 0; i < n; i++) { double _start = new Random().NextDouble() * 10; double _increment = new Random().NextDouble() * (5 - 0.0001) + 0.0001; arr[i] = new GeometricProgression(_start, _increment); if (arr[i][step] > geometric[step]) { Console.WriteLine(arr[i].ToString()); } } Console.WriteLine("\nВесь массив: "); for (int i = 0; i < n; i++) { Console.WriteLine(arr[i].ToString()); Console.WriteLine($"Сумма первых {step} членов: {arr[i].GetSum(step):f3}"); } Console.ReadLine(); } }
static void Main() { do { Console.Clear(); GeometricProgression progressionElement = new GeometricProgression(rnd.Next(0, 11) + rnd.NextDouble(), rnd.Next(0, 6) + rnd.NextDouble() + 0.00000001); Console.WriteLine($"Progression element: {progressionElement}"); int n = rnd.Next(5, 16); Console.WriteLine($"N: {n}"); GeometricProgression[] progressions = new GeometricProgression[n]; for (int i = 0; i < n; ++i) { progressions[i] = new GeometricProgression(rnd.Next(0, 11) + rnd.NextDouble(), rnd.Next(0, 6) + rnd.NextDouble() + 0.00000001); } Console.WriteLine("Progressions:"); foreach (var pr in progressions) { Console.WriteLine("\t" + pr); } int step = rnd.Next(3, 16); Console.WriteLine($"Step: {step}"); Console.WriteLine("Sequences[i][step] > SequenceElement[step]"); foreach (var pr in progressions) { if (pr[step] > progressionElement[step]) { Console.WriteLine("\t" + pr); } } Console.WriteLine("Sums: "); foreach (var pr in progressions) { Console.WriteLine($"\t{pr.GetSum(step):F3}"); } Console.WriteLine("Press Esc to exit. Press any other key to continue."); } while (Console.ReadKey(true).Key != ConsoleKey.Escape); }
static void Main(string[] args) { do { Random random = new Random(); GeometricProgression[] geometricProgressions = Enumerable.Range(0, random.Next(5, 16)).Select(eq => new GeometricProgression(random.Next(0, 11), random.Next(1, 6))).ToArray(); int step = random.Next(3, 16); GeometricProgression geometricProgression = new GeometricProgression(random.Next(0, 11), random.Next(1, 6)); Console.WriteLine($"step = {step}, случайная последовательность: {geometricProgression}"); foreach (var geometric in geometricProgressions.Select(eq => eq).Where(eq => eq[step] > geometricProgression[step])) { Console.WriteLine(geometric.ToString()); } foreach (var geometric in geometricProgressions) { Console.WriteLine(geometric.GetSum(step)); } Console.WriteLine("Для выхода нажмите esc, для повтора - любую другую клавишу."); } while (Console.ReadKey(true).Key != ConsoleKey.Escape); }
static void Main(string[] args) { do { Console.Clear(); int N; Random rand = new Random(); N = rand.Next(5, 16); GeometricProgression[] geometricProgressions = new GeometricProgression[N]; GeometricProgression geometricProgression; do { geometricProgression = new GeometricProgression(rand.Next(0, 11), rand.Next(0, 6)); } while (geometricProgression.Increment == 0); Console.WriteLine("Главная геометрическая прогрессия geometricProgression: " + geometricProgression.GetInfo()); Console.WriteLine("Созданные геометрические прогрессии:"); for (int i = 0; i < N; i++) { do { geometricProgressions[i] = new GeometricProgression(rand.Next(0, 11), rand.Next(0, 6)); } while (geometricProgressions[i].Increment == 0); Console.WriteLine((i + 1) + ". " + geometricProgressions[i].GetInfo()); } int step = rand.Next(3, 16); Console.WriteLine("step = " + step); Console.WriteLine($"Прогрессии, у которых элемент с номером {step} больше соответствующего элемента главной прогрессии:"); for (int i = 0; i < N; i++) { if (geometricProgressions[i][step] > geometricProgression[step]) { Console.WriteLine((i + 1) + ". " + geometricProgressions[i].GetInfo() + $", Sum({step}) = {geometricProgressions[i].GetSum(step)}"); } } Console.WriteLine(); Console.WriteLine("Для выхода из программы нажмите Escape, для продолжения - любую другую клавишу..."); } while (Console.ReadKey().Key != ConsoleKey.Escape); }
static void Main(string[] args) { while (true) { // Ввод данных об отдельном объекте-прогрессии. double start; do { Console.Write("Введите начальное значение последовательности: "); } while (!double.TryParse(Console.ReadLine(), out start)); double increment; do { Console.Write("Введите инкремент последовательности: "); } while (!double.TryParse(Console.ReadLine(), out increment)); Console.WriteLine(); GeometricProgression indProgression = new GeometricProgression(start, increment); Random rand = new Random(); // Создание массива случайных геометрических прогрессий. int N = rand.Next(5, 16); GeometricProgression[] geomProgArray = new GeometricProgression[N]; // Заполнение массива. for (int i = 0; i < geomProgArray.Length; i++) { geomProgArray[i] = new GeometricProgression(rand.Next(0, 10) + rand.NextDouble(), rand.Next(0, 4) + rand.NextDouble()); } int step = rand.Next(3, 16); // Вывод информации о прогрессиях с step-ым элементом большим, чем в отдельной. foreach (var geomProg in geomProgArray) { if (geomProg[step] > indProgression[step]) { Console.WriteLine(geomProg.ToString()); Console.WriteLine(); } } Console.WriteLine(); Console.WriteLine("======================================"); Console.WriteLine(); // Вывод суммы первых step членов прогрессий в массиве. for (int i = 0; i < geomProgArray.Length; i++) { Console.WriteLine($"Сумма первых {step} членов прогрессии {i + 1}: {geomProgArray[i].GetSum(step)}"); } Console.WriteLine(Environment.NewLine + "Нажмите Enter, чтобы выйти, или нажмите иную клавишу, чтобы продолжить."); if (Console.ReadKey().Key == ConsoleKey.Enter) { break; } else { Console.Clear(); } } }