Загрузка данных


using System;

class Program
{
    static void Main()
    {
        // ===== ЗАДАЧА 1 =====
        Console.WriteLine("=== Задача 1 ===");

        int[,] arr1 = new int[3, 3];
        Random rnd = new Random();

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                arr1[i, j] = rnd.Next(1, 10);
                Console.Write(arr1[i, j] + " ");
            }
            Console.WriteLine();
        }

        // а) Произведение элементов второго столбца
        int product1 = 1;
        for (int i = 0; i < 3; i++)
        {
            product1 *= arr1[i, 1];
        }
        bool isThreeDigit = product1 >= 100 && product1 <= 999;
        Console.WriteLine("Произведение 2-го столбца: " + product1);
        Console.WriteLine("Трёхзначное: " + isThreeDigit);

        // б) Сумма элементов строки с заданным номером
        Console.Write("Введите номер строки (0-2): ");
        int rowIndex1 = int.Parse(Console.ReadLine());
        Console.Write("Введите число для сравнения: ");
        int limit1 = int.Parse(Console.ReadLine());

        int sum1 = 0;
        for (int j = 0; j < 3; j++)
        {
            sum1 += arr1[rowIndex1, j];
        }
        Console.WriteLine("Сумма строки " + rowIndex1 + ": " + sum1);
        Console.WriteLine("Превышает " + limit1 + ": " + (sum1 > limit1));

        // ===== ЗАДАЧА 2 =====
        Console.WriteLine("\n=== Задача 2 ===");

        int[,] arr2 = new int[5, 4];

        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                arr2[i, j] = rnd.Next(1, 20);
                Console.Write(arr2[i, j] + " ");
            }
            Console.WriteLine();
        }

        // а) Сумма элементов 4-й строки (индекс 3)
        int sum2 = 0;
        for (int j = 0; j < 4; j++)
        {
            sum2 += arr2[3, j];
        }
        bool isTwoDigit = sum2 >= 10 && sum2 <= 99;
        Console.WriteLine("Сумма 4-й строки: " + sum2);
        Console.WriteLine("Двузначное: " + isTwoDigit);

        // б) Произведение элементов столбца с заданным номером
        Console.Write("Введите номер столбца (0-3): ");
        int colIndex2 = int.Parse(Console.ReadLine());
        Console.Write("Введите число для сравнения: ");
        int limit2 = int.Parse(Console.ReadLine());

        int product2 = 1;
        for (int i = 0; i < 5; i++)
        {
            product2 *= arr2[i, colIndex2];
        }
        Console.WriteLine("Произведение столбца " + colIndex2 + ": " + product2);
        Console.WriteLine("Не превышает " + limit2 + ": " + (product2 <= limit2));

        // ===== ЗАДАЧА 3 =====
        Console.WriteLine("\n=== Задача 3 ===");

        int[,] salary = new int[18, 12];

        for (int i = 0; i < 18; i++)
        {
            for (int j = 0; j < 12; j++)
            {
                salary[i, j] = rnd.Next(20000, 100000);
            }
        }

        int annualIncome = 0;
        for (int j = 0; j < 12; j++)
        {
            annualIncome += salary[0, j];
        }

        Console.Write("Введите число для сравнения годового дохода: ");
        int limit3 = int.Parse(Console.ReadLine());

        Console.WriteLine("Годовой доход первого человека: " + annualIncome);
        Console.WriteLine("Больше " + limit3 + ": " + (annualIncome > limit3));

        // ===== ЗАДАЧА 4 =====
        Console.WriteLine("\n=== Задача 4 ===");

        int[,] shops = new int[10, 12];

        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 12; j++)
            {
                shops[i, j] = rnd.Next(100000, 500000);
            }
        }

        // Сентябрь — индекс 8
        int septemberTotal = 0;
        for (int i = 0; i < 10; i++)
        {
            septemberTotal += shops[i, 8];
        }

        Console.Write("Введите число для сравнения дохода за сентябрь: ");
        int limit4 = int.Parse(Console.ReadLine());

        Console.WriteLine("Общий доход в сентябре: " + septemberTotal);
        Console. WriteLine("Превысил " + limit4 + ": " + (septemberTotal > limit4));

        // ===== ЗАДАЧА 5 =====
        Console.WriteLine("\n=== Задача 5 ===");

        int[,] hall = new int[23, 40];

        for (int i = 0; i < 23; i++)
        {
            for (int j = 0; j < 40; j++)
            {
                hall[i, j] = rnd.Next(0, 2);
            }
        }

        // Первый ряд — индекс 0
        bool hasFreeSeatsRow1 = false;
        for (int j = 0; j < 40; j++)
        {
            if (hall[0, j] == 0)
            {
                hasFreeSeatsRow1 = true;
                break;
            }
        }
        Console.WriteLine("Есть свободные места в первом ряду: " + hasFreeSeatsRow1);

        // ===== ЗАДАЧА 6 =====
        Console.WriteLine("\n=== Задача 6 ===");

        int[,] train = new int[18, 36];

        for (int i = 0; i < 18; i++)
        {
            for (int j = 0; j < 36; j++)
            {
                train[i, j] = rnd.Next(0, 2);
            }
        }

        Console.Write("Введите номер вагона (1-18): ");
        int wagonNumber = int.Parse(Console.ReadLine());
        int wagonIndex = wagonNumber - 1;

        bool hasFreeSeatsWagon = false;
        for (int j = 0; j < 36; j++)
        {
            if (train[wagonIndex, j] == 0)
            {
                hasFreeSeatsWagon = true;
                break;
            }
        }
        Console.WriteLine("Есть свободные места в вагоне " + wagonNumber + ": " + hasFreeSeatsWagon);
    }
}