Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ArithmeticSequence arithmetic = new ArithmeticSequence(300, 5);
            int N = rnd.Next(5, 16);

            ArithmeticSequence[] array = new ArithmeticSequence[N];
            for (int i = 0; i < N; ++i)
            {
                array[i] = new ArithmeticSequence(rnd.Next(0, 1001), rnd.Next(1, 11));
            }
            int step = rnd.Next(3, 16);

            Console.WriteLine("step = " + step + '\n');
            for (int i = 0; i < N; ++i)
            {
                if (array[i][step] > arithmetic[step])
                {
                    Console.WriteLine($"{i}: {array[i]}");
                }
            }
            Console.WriteLine();
            for (int i = 0; i < N; ++i)
            {
                Console.WriteLine($"{i}: {array[i]} Сумма первых {step} членов: {array[i].GetSum(step)}");
            }
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            do
            {
                Console.Clear();
                int n = random.Next(5, 16);
                ArithmeticSequence[] arr = new ArithmeticSequence[n];
                ArithmeticSequence   b   = new ArithmeticSequence(random.Next(0, 1000) + random.NextDouble(),
                                                                  random.Next(1, 10) + random.NextDouble());

                for (int i = 0; i < arr.Length; i++)
                {
                    arr[i] = new ArithmeticSequence(random.Next(0, 1000) + random.NextDouble(),
                                                    random.Next(1, 10) + random.NextDouble());
                }
                Console.WriteLine("*****************");
                int step = random.Next(3, 15);
                Console.WriteLine(b);
                Console.WriteLine("\t" + b.GetSum(step).ToString("f3"));
                Console.WriteLine("*****************");
                for (int i = 0; i < arr.Length; i++)
                {
                    if (arr[i][step] > b[step])
                    {
                        Console.WriteLine(arr[i]);
                        Console.WriteLine("\t" + arr[i][step].ToString("f3"));
                        Console.WriteLine("\t" + b[step].ToString("f3"));
                    }
                }

                Console.WriteLine("*****************");
                for (int i = 0; i < arr.Length; i++)
                {
                    Console.WriteLine(arr[i]);
                    Console.WriteLine("\t" + arr[i].GetSum(step).ToString("f3"));
                }
            } while (Console.ReadKey(true).Key != ConsoleKey.Escape);
        }