Ejemplo n.º 1
0
        static void getNoPositive()
        {
            int[,,] mas = { { { 1, 2, -3, 4 } }, { { 5, -6, -10, 11 } }, { { 2, 3, 4, -5 } } };

            /*int[,,] mas = { { { -1, 0 }, { -3, 4 } },
             *              { { -4, 5 }, { -6, 7 } },
             *              { { -7, 8 }, { -9, 2 } },
             *              { { -7, 9 }, { -1, 1 } } };*/


            int rows     = mas.GetUpperBound(0) + 1;
            int columns1 = mas.GetUpperBound(1) + 1;
            int columns2 = mas.GetUpperBound(2) + 1;

            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns1; j++)
                {
                    for (int a = 0; a < columns2; a++)
                    {
                        if (mas[i, j, a] >= 0)
                        {
                            mas[i, j, a] = 0;
                        }
                        Console.Write($"{mas[i, j, a]} \t");
                    }
                }
                Console.WriteLine();
            }
        }
Ejemplo n.º 2
0
 /**********************************************************************
  *********************************************************************/
 //print 3d array
 static void PrintRam(int[,,] array)
 {
     // Loop over 3D int array and display it.
     for (int i = 0; i <= array.GetUpperBound(0); i++)
     {
         String s = "";
         for (int j = 0; j <= array.GetUpperBound(1); j++)
         {
             String rbit = "x";
             String mbit = "x";
             //if rbit is set
             if (array[i, j, 1] == 1)
             {
                 rbit = "r";
             }
             //if mbit is set
             if (array[i, j, 2] == 1)
             {
                 mbit = "m";
             }
             //if page is not -1
             s += array[i, j, 0] + rbit + mbit;
             s += " ";
         }
         Debug.WriteLine(s);
     }
 }
        public void Draw()
        {
            int z = 0;
            for (var y = 0; y <= Matrix.GetUpperBound(1); y++)
            {
                for (var x = 0; x <= Matrix.GetUpperBound(0); x++)
                {
                    if (Matrix[x, y, z] == 8)
                    {
                        Console.Write("A ");
                        continue;
                    }
                    else if (Matrix[x, y, z] == 9)
                    {
                        Console.Write("Z ");
                        continue;
                    }
                    else if (Matrix[x, y, z] == 5)
                    {
                        Console.Write("N ");
                        continue;
                    }
                  

                    if (Matrix[x, y, z] == 1) { Console.Write("# "); continue; }
                    else { Console.Write("0 "); }
                }
                Console.WriteLine();
            }
        }
Ejemplo n.º 4
0
        //show 壓縮率&失真率
        private void button3_Click(object sender, EventArgs e)
        {
            int result;//失真率
            //計算失真率
            int temp = 0, count = 0;

            for (int i = 0; i < COMdata.GetUpperBound(0); i++)
            {
                for (int j = 0; j < COMdata.GetUpperBound(1); j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        temp += Math.Abs(COMdata[i, j, k] - RGBdata[i, j, k]);
                        count++;
                    }
                }
            }
            result = temp / count;

            //計算壓縮率
            String x        = Filename;
            Double s1       = new FileInfo(x).Length;
            Double s2       = new FileInfo(new_filename).Length;
            int    compress = (int)(s2 / s1 * 100);

            MessageBox.Show("失真率:" + result + "%" + "\n壓縮率:" + compress + "%");
        }
Ejemplo n.º 5
0
        public Cluster(int[,,] clusterMatrix)
        {
            Matrix = clusterMatrix;

            int z = 0;

            for (int y = 0; y <= Matrix.GetUpperBound(1); y += Matrix.GetUpperBound(1))
            {
                ClusterEdge clusterEdge1 = new ClusterEdge();
                clusterEdge1.NodesLocations = new List <Location>();

                ClusterEdge clusterEdge2 = new ClusterEdge();
                clusterEdge2.NodesLocations = new List <Location>();

                for (int x = 0; x <= Matrix.GetUpperBound(0); x++)
                {
                    Location nodeLocation1 = new Location(x, y, z);
                    Location nodeLocation2 = new Location(y, x, z);

                    clusterEdge1.NodesLocations.Add(nodeLocation1);
                    clusterEdge2.NodesLocations.Add(nodeLocation2);
                }
                ClusterEdges.Add(clusterEdge1);
                ClusterEdges.Add(clusterEdge2);
            }
        }
Ejemplo n.º 6
0
 private static bool IsValidElement(int[, ,] intArray, int X, int Y, int Z)
 {
     return(X >= 0 && Y >= 0 && Z >= 0 &&
            X <= intArray.GetUpperBound(0) &&
            Y <= intArray.GetUpperBound(1) &&
            Z <= intArray.GetUpperBound(2));
 }
Ejemplo n.º 7
0
        private void cmdInit_Click(object sender, EventArgs e)
        {
            // Beispiele für direktes initialisieren von Datenfeldern / Arrays
            //
            int[] a = { 0, 5, -2, 7 };

            //[2,3]
            double[,] b = { { 6.2, 2.0, -1.8 }, { 9.3, 3.6, -2.3 } };

            //[2,2,3]
            int[,,] c = { { { 9, -3, 2 }, { 2, 1, -5 } }, { { 3, 9, 8 }, { 6, 3, -8 } } };

            lblAnzeigen2.Text = "";
            for (int i = 0; i <= c.GetUpperBound(0); i++)
            {
                for (int j = 0; j <= c.GetUpperBound(1); j++)
                {
                    lblAnzeigen2.Text += " ( ";
                    for (int k = 0; k <= c.GetUpperBound(2); k++)
                    {
                        lblAnzeigen2.Text += c[i, j, k] + " ";
                    }

                    lblAnzeigen2.Text += " ) ";
                }

                lblAnzeigen2.Text += "\n";
            }
        }
Ejemplo n.º 8
0
 public static bool IsValidPositionInArray3D(this int[, ,] intArray, int X, int Y, int Z)
 {
     return(X >= 0 && Y >= 0 && Z >= 0 &&
            X <= intArray.GetUpperBound(0) &&
            Y <= intArray.GetUpperBound(1) &&
            Z <= intArray.GetUpperBound(2));
 }
Ejemplo n.º 9
0
 static void Initialize(int[,,] s)
 {
     for (int i = s.GetLowerBound(0); i <= s.GetUpperBound(0); i++)
     {
         for (int j = s.GetLowerBound(1); j <= s.GetUpperBound(1); j++)
         {
             for (int k = s.GetLowerBound(2); k <= s.GetUpperBound(2); k++)
             {
                 s[i, j, k] = (2 * i) - (3 * j) + (5 * k);
             }
         }
     }
 }
Ejemplo n.º 10
0
 private static void WriteArray(int[,,] arr)
 {
     Console.WriteLine("Элементы массива:");
     for (int i = 0; i <= arr.GetUpperBound(0); i++)
     {
         for (int j = 0; j <= arr.GetUpperBound(1); j++)
         {
             for (int b = 0; b <= arr.GetUpperBound(2); b++)
             {
                 Console.WriteLine($"Array[{i},{j},{b}]: {arr[i, j, b]}");
             }
         }
     }
 }
Ejemplo n.º 11
0
        private Bitmap ToBitmap(int[,,] act)
        {
            Bitmap newer = new Bitmap(act.GetUpperBound(0) + 1, act.GetUpperBound(1) + 1);

            for (int x = 0; x < act.GetUpperBound(0) + 1; x++)
            {
                for (int y = 0; y < act.GetUpperBound(1) + 1; y++)
                {
                    System.Drawing.Color meh = System.Drawing.Color.FromArgb(act[x, y, 0], act[x, y, 1], act[x, y, 2]);
                    newer.SetPixel(x, y, meh);
                }
            }
            return(newer);
        }
Ejemplo n.º 12
0
        public Task1()
        {
            int[,,] mas =
            {
                { {  1,  2 }, {  3,  4 } },
                { {  4,  5 }, {  6,  7 } },
                { {  7,  8 }, {  9, 10 } },
                { { 10, 11 }, { 12, 13 } }
            };

            int x = mas.GetUpperBound(0);
            int y = mas.GetUpperBound(1);
            int z = mas.GetUpperBound(2);

            string result = "{";

            for (int i = 0; i < x + 1; i++)
            {
                result += "{";
                for (int j = 0; j < y + 1; j++)
                {
                    result += "{";
                    for (int k = 0; k < z + 1; k++)
                    {
                        result += mas[i, j, k];

                        if (k != z)
                        {
                            result += ",";
                        }
                    }
                    result += "}";

                    if (j != y)
                    {
                        result += ",";
                    }
                }
                result += "}";

                if (i != x)
                {
                    result += ",";
                }
            }
            result += "}";

            Console.WriteLine(result);
        }
Ejemplo n.º 13
0
        public static void ArrayElements(int[,,] array)
        {
            var random1 = new Random();

            for (int i = 0; i < array.GetUpperBound(0) + 1; i++)
            {
                for (int j = 0; j < array.GetUpperBound(1) + 1; j++)
                {
                    for (int k = 0; k < array.GetUpperBound(2) + 1; k++)
                    {
                        array[i, j, k] = random1.Next(1, 100);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public static void FillRand(this int[,,] items, int min, int max)
        {
            Random r = new Random();

            for (int i = 0; i <= items.GetUpperBound(0); i++)
            {
                for (int j = 0; j <= items.GetUpperBound(1); j++)
                {
                    for (int k = 0; k <= items.GetUpperBound(2); k++)
                    {
                        items[i, j, k] = r.Next(min, max);
                    }
                }
            }
        }
Ejemplo n.º 15
0
 static void ArrayPrint(int[,,] array)
 {
     for (int i = 0; i < array.GetUpperBound(0) + 1; i++)
     {
         for (int j = 0; j < array.GetUpperBound(1) + 1; j++)
         {
             for (int k = 0; k < array.GetUpperBound(2) + 1; k++)
             {
                 Console.Write(array[i, j, k] + " ");
             }
             Console.WriteLine();
         }
         Console.WriteLine();
     }
 }
Ejemplo n.º 16
0
        public void DrawSquare()
        {
            for (var z = 0; z <= Matrix.GetUpperBound(2); z++)
            {
                for (var y = 0; y <= Matrix.GetUpperBound(1); y++)
                {
                    for (var x = 0; x <= Matrix.GetUpperBound(0); x++)
                    {
                        bool pt = false;
                        if (Matrix[x, y, z] == 1)
                        {
                            Console.Write("# "); continue;
                        }
                        else if (Matrix[x, y, z] == 8)
                        {
                            Console.Write("A "); continue;
                        }
                        else if (Matrix[x, y, z] == 9)
                        {
                            Console.Write("Z "); continue;
                        }

                        if (Path != null)
                        {
                            foreach (PathFinderNode item in Path)
                            {
                                if (item.X == x && item.Y == y && item.Z == z)
                                {
                                    Console.Write("* ");
                                    pt = true;
                                    break;
                                }
                            }
                        }

                        if (pt)
                        {
                            continue;
                        }
                        else
                        {
                            Console.Write("0 ");
                        }
                    }
                    Console.WriteLine();
                }
            }
        }
Ejemplo n.º 17
0
 /**********************************************************************
  *********************************************************************/
 static void InitializeRam(int[,,] array)
 {
     // Loop over 2D int array and fill it with default values
     for (int i = 0; i <= array.GetUpperBound(0); i++)
     {
         for (int j = 0; j <= array.GetUpperBound(1); j++)
         {
             array[i, j, 0] = -1; //-1 means no page (pages range from 0 to 9)
             array[i, j, 1] = 0;  //r-bit is not set
             array[i, j, 2] = 0;  //m-bit is not set
             array[i, j, 3] = 0;  //no pagefail
             array[i, j, 4] = 0;  //no r-bits were reset
             array[i, j, 5] = 0;  //no m-bit was set
         }
     }
 }
Ejemplo n.º 18
0
 public static void ArrayReplacement(int[,,] array)
 {
     for (int i = 0; i < array.GetUpperBound(0) + 1; i++)
     {
         for (int j = 0; j < array.GetUpperBound(1) + 1; j++)
         {
             for (int k = 0; k < array.GetUpperBound(2) + 1; k++)
             {
                 if (array[i, j, k] > 0)
                 {
                     array[i, j, k] = 0;
                 }
             }
         }
     }
 }
Ejemplo n.º 19
0
        //=========================================================

        static void show3D_Array(int[,,] array)
        {
            for (int i = 0; i <= array.GetUpperBound(0); i++)
            {
                for (int j = 0; j <= array.GetUpperBound(1); j++)
                {
                    for (int k = 0; k <= array.GetUpperBound(2); k++)
                    {
                        Console.Write("(Row={0, 2}, Column={1, 2}, Depth={2, 2}) Value={3, 2} \t", i, j, k, array[i, j, k]);
                    }
                    Console.WriteLine();
                }
                Console.WriteLine("-------------------------------------------------------------------->>");
            }
            Console.WriteLine("\n \n");
        }
Ejemplo n.º 20
0
 private static void RemovePositive(int[,,] arr)
 {
     for (int i = 0; i <= arr.GetUpperBound(0); i++)
     {
         for (int j = 0; j <= arr.GetUpperBound(1); j++)
         {
             for (int b = 0; b <= arr.GetUpperBound(2); b++)
             {
                 if (arr[i, j, b] > 0)
                 {
                     arr[i, j, b] = 0;
                 }
             }
         }
     }
 }
Ejemplo n.º 21
0
 public static void Main_(string[] args)
 {
     //jagged
     int[][] arJ = new int[5][];
     arJ[0] = new int[2];
     arJ[1] = new int[1];
     arJ[2] = new int[2];
     arJ[3] = new int[1];
     arJ[4] = new int[0];
     Console.WriteLine("\n");
     for (var a = 0; a < arJ.Length; a++)
     {
         for (var b = 0; b < arJ[a].Length; b++)
         {
             Console.WriteLine($"a{a}b{b} arJ[a][b] {arJ[a][b]}");
         }
         ;
     }
     Console.WriteLine("\n");
     //multi
     //int[,,] arM = new int[2,4,3]; //or
     int[,,] arM = { { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 } }, { { 13, 14, 15 }, { 16, 17, 18 }, { 19, 20, 21 }, { 22, 23, 24 } } };
     Console.WriteLine($"arM[1,1,1] {arM[1,1,1]}");
     Console.WriteLine($"arM.Length {arM.Length}");
     Console.WriteLine($"arM.Rank {arM.Rank}");
     for (int r = 0; r < arM.Rank; r++)
     {
         Console.WriteLine($"Dimension {r+1} {arM.GetUpperBound(r)+1}");
     }
     Console.WriteLine("\n");
     foreach (var a in arM)
     {
         Console.WriteLine(a);
     }
 }
Ejemplo n.º 22
0
        public static string Display(this int[,,] items)
        {
            string ToDisplay = string.Empty;

            for (int i = 0; i <= items.GetUpperBound(0); i++)
            {
                ToDisplay += "\n\r";
                for (int j = 0; j <= items.GetUpperBound(1); j++)
                {
                    for (int k = 0; k <= items.GetUpperBound(2); k++)
                    {
                        ToDisplay += items[i, j, k].ToString() + " ";
                    }
                }
            }
            return(ToDisplay);
        }
Ejemplo n.º 23
0
        public MatrixIterator(Cluster cluster, IMatrixIterateOption option)
        {
            this.cluster = cluster;
            this.option  = option;

            int[,,] matrix = this.cluster.Matrix;

            for (int z = 0; z <= matrix.GetUpperBound(2); z++)
            {
                for (int y = 0; y <= matrix.GetUpperBound(1); y++)
                {
                    for (int x = 0; x <= matrix.GetUpperBound(0); x++)
                    {
                        this.option.Set(x, y, z);
                    }
                }
            }
        }
Ejemplo n.º 24
0
        static bool VerifyCopy(int[,,] s, int[,,] d)
        {
            for (int i = s.GetLowerBound(0); i <= s.GetUpperBound(0); i++)
            {
                for (int j = s.GetLowerBound(1); j <= s.GetUpperBound(1); j++)
                {
                    for (int k = s.GetLowerBound(2); k <= s.GetUpperBound(2); k++)
                    {
                        if (s[i, j, k] != d[i, j, k])
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 25
0
        private void CmdAnzeige_Click(object sender, EventArgs e)
        {
            a = new int[6, 3, 4];

            MinWertIndex = "";


            LstSpalte0Zeile0.Items.Clear();
            LstSpalte1Zeile0.Items.Clear();
            LstSpalte2Zeile0.Items.Clear();
            LstSpalte0Zeile1.Items.Clear();
            LstSpalte1Zeile1.Items.Clear();
            LstSpalte2Zeile1.Items.Clear();
            LstSpalte0Zeile2.Items.Clear();
            LstSpalte1Zeile2.Items.Clear();
            LstSpalte2Zeile2.Items.Clear();
            LstSpalte0Zeile3.Items.Clear();
            LstSpalte1Zeile3.Items.Clear();
            LstSpalte2Zeile3.Items.Clear();

            for (i = 0; i <= a.GetUpperBound(0); i++)
            {
                for (k = 0; k <= a.GetUpperBound(1); k++)
                {
                    for (l = 0; l <= a.GetUpperBound(2); l++)
                    {
                        a[i, k, l] = r.Next(20, 31);
                    }
                }

                LstSpalte0Zeile0.Items.Add(a[i, 0, 0]);
                LstSpalte1Zeile0.Items.Add(a[i, 1, 0]);
                LstSpalte2Zeile0.Items.Add(a[i, 2, 0]);
                LstSpalte0Zeile1.Items.Add(a[i, 0, 1]);
                LstSpalte1Zeile1.Items.Add(a[i, 1, 1]);
                LstSpalte2Zeile1.Items.Add(a[i, 2, 1]);
                LstSpalte0Zeile2.Items.Add(a[i, 0, 2]);
                LstSpalte1Zeile2.Items.Add(a[i, 1, 2]);
                LstSpalte2Zeile2.Items.Add(a[i, 2, 2]);
                LstSpalte0Zeile3.Items.Add(a[i, 0, 3]);
                LstSpalte1Zeile3.Items.Add(a[i, 1, 3]);
                LstSpalte2Zeile3.Items.Add(a[i, 2, 3]);
            }
        }
Ejemplo n.º 26
0
        static void Metanit1()
        {
            //С помощью циклов переберите все элементы этого массива и выведите их на консоль в следующем виде:
            //{{{1 , 2} , {3 , 4}} , {{4 , 5} , {6 , 7}} , {{7 , 8}, {9 , 10}} , {{10 , 11} , {12 , 13}}}
            int[,,] mas = { { {  1,  2 }, {  3,  4 } },
                            { {  4,  5 }, {  6,  7 } },
                            { {  7,  8 }, {  9, 10 } },
                            { { 10, 11 }, { 12, 13 } } };
            int firstLayer  = mas.GetUpperBound(0);
            int secondLayer = mas.GetUpperBound(1);
            int thirdLayer  = mas.GetUpperBound(2);

            Console.Write("{");
            for (int i = 0; i <= firstLayer; i++)
            {
                Console.Write("{");
                for (int j = 0; j <= secondLayer; j++)
                {
                    Console.Write("{");
                    for (int k = 0; k <= thirdLayer; k++)
                    {
                        Console.Write(mas[i, j, k]);
                        if (k < thirdLayer)
                        {
                            Console.Write(" , ");
                        }
                    }

                    Console.Write("}");
                    if (j < secondLayer)
                    {
                        Console.Write(" , ");
                    }
                }
                Console.Write("}");

                if (i < firstLayer)
                {
                    Console.Write(" , ");
                }
            }
            Console.Write("}");
            Console.ReadLine();
        }
Ejemplo n.º 27
0
        private static void ReplacePos(ref int[,,] array)
        {
            for (int i = array.GetLowerBound(0); i <= array.GetUpperBound(0); i++)
            {
                for (int j = array.GetLowerBound(1); j <= array.GetUpperBound(1); j++)
                {
                    for (int k = array.GetLowerBound(2); k <= array.GetUpperBound(2); k++)
                    {
                        if (array[i, j, k] > 0)
                        {
                            array[i, j, k] = 0;
                        }

                        Console.Write($"{array[i, j, k]} ");
                    }

                    Console.WriteLine();
                }
            }
        }
Ejemplo n.º 28
0
        public static void NoPositive(int[, ,] arr)
        {
            int firstdimension  = arr.GetUpperBound(0);
            int seconddimension = arr.GetUpperBound(1);
            int thirddimension  = arr.GetUpperBound(2);

            for (int i = 0; i <= firstdimension; i++)
            {
                for (int j = 0; j <= seconddimension; j++)
                {
                    for (int k = 0; k <= thirddimension; k++)
                    {
                        if (arr[i, j, k] > 0)
                        {
                            arr[i, j, k] = 0;
                        }
                    }
                }
            }
        }
Ejemplo n.º 29
0
    public void meshCopy(int[,,] world, GameObject [,,] worldObjects, GameObject Go)
    {
        int GOcnt = 0;

        for (int x = world.GetLowerBound(0); x < world.GetUpperBound(0); x++)
        {
            for (int y = world.GetLowerBound(1); y < world.GetUpperBound(1); y++)
            {
                for (int z = world.GetLowerBound(2); z < world.GetUpperBound(2); z++)
                {
                    if (world[x, y, z] == 1)
                    {
                        worldObjects[x, y, z] = (GameObject)Instantiate(Go, new Vector3(x, y, z), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f));
                        GOcnt = GOcnt + 1;
                        worldObjects[x, y, z].name = "GOgen_" + GOcnt;
                    }
                }
            }
        }
    }
Ejemplo n.º 30
0
        static void SetZeroPositiveValue(int[,,] array)
        {
            int dimension = array.GetUpperBound(0) + 1;
            int rows      = array.GetUpperBound(1) + 1;
            int columns   = array.GetUpperBound(2) + 1;

            for (int i = 0; i < dimension; i++)
            {
                for (int j = 0; j < rows; j++)
                {
                    for (int k = 0; k < columns; k++)
                    {
                        if (array[i, j, k] > 0)
                        {
                            array[i, j, k] = 0;
                        }
                    }
                }
            }
        }