Beispiel #1
0
        public static DateTime Writinggame(int[,,] array)
        {
            DateTime dt = DateTime.Now;

            string namefile = DateTime.Now.ToString("yyyyMMddhhmmss");

            namefile += ".txt";

            using (StreamWriter sw = new System.IO.StreamWriter(namefile))
            {
                for (int j = 0; j < array.GetLongLength(0); j++)
                {
                    sw.WriteLine();
                    for (int k = 0; k < array.GetLongLength(1); k++)
                    {
                        for (int i = 0; i < array.GetLongLength(2); i++)
                        {
                            sw.Write(String.Format($"{array[j, k, i]} "));
                        }
                        sw.WriteLine();
                    }
                }
                sw.Close();
            }
            return(dt);
        }
Beispiel #2
0
        internal static void InitializelArray(int[,,] array)
        {
            Random r = new Random();

            for (int i = 0; i < array.GetLongLength(0); i++)
            {
                for (int j = 0; j < array.GetLongLength(1); j++)
                {
                    for (int k = 0; k < array.GetLongLength(2); k++)
                    {
                        array[i, j, k] = r.Next(-50, 50);
                    }
                }
            }
        }
    static void PrintCuboid(int[, ,] cuboid)
    {
        for (int i = 0; i cuboid.GetLongLength(1); i++)
        {
            for (int j = 0; j cuboid.GetLongLength(2); j++)
            {
                for (int k = 0; k cuboid.GetLongLength(0); k++)
                {
                    Console.Write(cuboid[k, i, j] +);
                }
                Console.Write( );
            }

            Console.WriteLine();
        }
    }
Beispiel #4
0
 internal static void NoPositive(int[,,] array)
 {
     for (int i = 0; i < array.GetLongLength(0); i++)
     {
         for (int j = 0; j < array.GetLongLength(1); j++)
         {
             for (int k = 0; k < array.GetLongLength(2); k++)
             {
                 if (array[i, j, k] > 0)
                 {
                     array[i, j, k] = 0;
                 }
             }
         }
     }
 }
    static void InitializeCuboid(int[, ,] cuboid)
    {
        for (int i = 0; i cuboid.GetLongLength(1); i++)
        {
            int[] tokens = Console.ReadLine().Split(new char[] { ' ', '' },
                                                    StringSplitOptions.RemoveEmptyEntries).Select(ch = int.Parse(ch)).ToArray();
            int count = 0;

            for (int j = 0; j cuboid.GetLongLength(2); j++)
            {
                for (int k = 0; k cuboid.GetLongLength(0); k++)
                {
                    cuboid[k, i, j] = tokens[count++];
                }
            }
        }
    }
Beispiel #6
0
        internal static void ShowArrayInfo(int[,,] array)
        {
            for (int i = 0; i < array.GetLongLength(0); i++)
            {
                for (int j = 0; j < array.GetLongLength(1); j++)
                {
                    for (int k = 0; k < array.GetLongLength(2); k++)
                    {
                        Console.Write($"{array[k, j, i]}, ");
                    }

                    Console.WriteLine();
                }

                Console.WriteLine();
            }
        }
        public int[,,,] MultMatrizNxNxN(int[,,] matrizA, int[,,] matrizB)
        {
            long size = matrizA.GetLongLength(0);

            int[,,,] matrizResult = new int[size, size, size, size];
            int aux;

            stopwatch.Start();


            for (int u = 0; u < size; u++)
            {
                for (int z = 0; z < size; z++)
                {
                    for (int l = 0; l < size; l++)
                    {
                        //Variação eixo Y == coluna
                        for (int y = 0; y < size; y++)
                        {
                            //Variação eixo X == linha
                            for (int x = 0; x < size; x++)
                            {
                                aux = 0;
                                for (int k = 0; k < size; k++)
                                {
                                    aux += matrizA[z, y, k] * matrizB[l, k, x];
                                }

                                matrizResult[u, z, y, x] = aux;
                            }
                        }
                    }
                }
            }

            stopwatch.Stop();
            //Printa o tempo gasto neste metodo;
            Console.WriteLine("Tempo gasto para a multiplicação NxNxN " + stopwatch.Elapsed);
            return(matrizResult);
        }