Example #1
0
    static void Main()
    {
        double count;

        Console.WriteLine("Введите кол-во палат в больнице");
        int n = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("Введите кол-во коек в каждой палате");
        int m = Convert.ToInt32(Console.ReadLine());

        double[,] hosp = new double[n, m];
        for (int i = 0; i < hosp.GetLength(0); i++)
        {
            for (int j = 0; j < hosp.GetLength(1); j++)
            {
                Console.WriteLine("Введите температуру пациента, находящегося на койке {0}  в палате {1}", j + 1, i + 1);
                count      = Convert.ToDouble(Console.ReadLine());
                hosp[i, j] = count;
            }
        }
        Console.WriteLine("Обычная реализация:\n");
        SolvingTaskMassive.SimpleMassiveObjective(hosp);
        Console.WriteLine("\n\nУпрощенная реализация с использованием Array:\n");
        SolvingTaskMassive.ArrayObjective(hosp);
    }
Example #2
0
    static void Main()
    {
        unsafe
        {
            int rows    = 10,
                columns = 4;

            int *ptr = stackalloc int[rows * columns];
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    ptr[i * columns + j] = rows;
                }
            }
            int counter = default(int);
            for (int i = 0; i < rows; i++)
            {
                Console.WriteLine("В палате {0} находится {1} коек(и).\n", i + 1, rows);
                for (int j = 0; j < columns; j++)
                {
                    if (ptr[i * columns + j] != 0 || ptr[i * columns + j] > 0)
                    {
                        counter++;
                        Console.WriteLine("В койке {0} лежит пациент с температурой {1}", j + 1, ptr[i * columns + j]);
                    }
                }
            }
            //
            double count;
            Console.WriteLine("Введите кол-во палат в больнице");
            int n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Введите кол-во коек в каждой палате");
            int     m    = Convert.ToInt32(Console.ReadLine());
            double *hosp = stackalloc double[n * m];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    Console.WriteLine("Введите температуру пациента, находящегося на койке {0}  в палате {1}", j + 1, i + 1);
                    count           = Convert.ToDouble(Console.ReadLine());
                    hosp[i * m + j] = count;
                }
            }
            Console.WriteLine("Обычная реализация:\n");
            SolvingTaskMassive.SimpleMassiveObjective(hosp, n, m);
        }
    }