Example #1
0
 private void IsiArray()
 {
     int[] Fibo = FunctionBase.Fibo(JumlahKolom);
     for (int b = 0; b < JumlahBaris; b++)
     {
         for (int k = 0; k < JumlahKolom; k++)
         {
             if (b == k || b + k == JumlahBaris - 1)
             {
                 Array2D[b, k] = Fibo[k].ToString();
             }
             else if (b < k && b + k < JumlahBaris - 1)
             {
                 Array2D[b, k] = "A";
             }
             else if (b < k && b + k >= JumlahBaris - 1)
             {
                 Array2D[b, k] = "B";
             }
             else if (b > k && b + k > JumlahBaris - 1)
             {
                 Array2D[b, k] = "C";
             }
             else
             {
                 Array2D[b, k] = "D";
             }
         }
     }
 }
Example #2
0
        private void IsiArray()
        {
            int ascii = 65;

            int [] Fibo = FunctionBase.Fibo(JumlahKolom);
            for (int b = 0; b < JumlahBaris; b++)
            {
                for (int k = 0; k < JumlahKolom; k++)
                {
                    //diagonal
                    if (b == k)
                    {
                        Array2D[b, k] = Fibo[b].ToString();                   //kiri ke kanan
                        Array2D[b, JumlahKolom - k - 1] = Fibo[b].ToString(); // Refleksi kanan kiri
                    }
                    //diagonal tengah
                    else if (b + k == (JumlahKolom - 1) / 2)
                    {
                        Array2D[b, k] = Fibo[k].ToString();                   //kanan
                        Array2D[b, JumlahKolom - k - 1] = Fibo[k].ToString(); //refleksi kiri
                    }
                    //tengah baris
                    else if (b == JumlahBaris / 2 && k <= JumlahKolom / 2)
                    {
                        Array2D[b, k] = ((char)ascii).ToString();                   // kiri ke kanan
                        Array2D[b, JumlahKolom - k - 1] = ((char)ascii).ToString(); //refleksi kanan ke kiri
                        ascii++;
                    }
                }
            }
        }
Example #3
0
        private void IsiArray(int n)
        {
            int[] Fibo = FunctionBase.Fibo(JumlahKolom * JumlahKolom);
            for (int bangun = 0; bangun < n; bangun++)
            {
                //Start End
                int StarBar = n * bangun;
                int StarKol = bangun % 2 * (n * 2 - 1);
                int EndBar  = StarBar + (n - 1);
                int EndKol  = StarKol + 2 * (n - 1);

                // Index Fibo
                int index  = 0;
                int ganjil = 1;
                for (int b = StarBar; b <= EndBar; b++)
                {
                    for (int k = StarKol; k <= EndKol; k++)
                    {
                        if (b + k >= StarKol + EndBar && k - b <= EndKol - EndBar)
                        {
                            if (bangun % 2 == 0)
                            {
                                //if (b + k >= StarKol + EndBar && k - b <= EndKol - EndBar)
                                Array2D[b, k] = Fibo[index++].ToString();
                            }
                            else
                            {
                                Array2D[b, k] = ganjil.ToString();
                            }
                            ganjil += 2;
                        }
                    }
                }
            }
        }
Example #4
0
 private void IsiArray(int n)
 {
     int[] fibo = FunctionBase.Fibo(n * n);
     for (int bb = 0; bb < n; bb++)
     {
         for (int bk = 0; bk < n; bk++)
         {
             if (bb == bk)
             {
                 int angka  = 0;
                 int nAngka = n * 2 + (n - 2) * 2 - 1;
                 int sBaris = bb * n;
                 int sKolom = bk * n;
                 int eBaris = sBaris + n - 1;
                 int eKolom = sKolom + n - 1;
                 for (int b = sBaris; b <= eBaris; b++)
                 {
                     for (int k = sKolom; k <= eKolom; k++)
                     {
                         if (b == sBaris || k == eKolom)
                         {
                             Array2D[b, k] = "" + fibo[angka++];
                         }
                         else if (b == eBaris || k == sKolom)
                         {
                             Array2D[b, k] = "" + fibo[nAngka--];
                         }
                     }
                 }
             }
         }
     }
 }
        private void IsiArray(int n)
        {
            int[] Fibo  = FunctionBase.Fibo(JumlahKolom * JumlahKolom);
            int   index = 0;

            for (int bangun = 0; bangun < n; bangun++)
            {
                int StarBar = (bangun * bangun + bangun) / 2;
                int EndBar  = StarBar + bangun;
                int StarKol = JumlahKolom - 1 - StarBar - EndBar;
                int EndKol  = JumlahKolom - (bangun * bangun) - 1;

                for (int b = StarBar; b <= EndBar; b++)
                {
                    for (int k = StarKol; k <= EndKol; k++)
                    {
                        if (b + k == EndBar + StarKol || b - k == EndBar - EndKol || b == EndBar)
                        {
                            if (b + k >= StarKol + EndBar && k + EndBar <= b + EndKol)
                            {
                                Array2D[b, k] = Fibo[index++].ToString();
                            }
                        }
                    }
                }
            }
        }
Example #6
0
        private void IsiArray()
        {
            int[] fibo  = FunctionBase.Fibo(JumlahKolom);
            int   ascii = 64;

            for (int b = 0; b < JumlahBaris; b++)
            {
                for (int k = 0; k < JumlahKolom; k++)
                {
                    if (b <= k && b + k <= JumlahBaris - 1)
                    {
                        Array2D[b, k] = b % 2 == 0 ? fibo[b / 2].ToString() : ((char)(ascii + (b + 1) / 2)).ToString();
                        Array2D[JumlahKolom - 1 - b, k] = b % 2 == 0 ? fibo[b / 2].ToString() : ((char)(ascii + (b + 1) / 2)).ToString();

                        /*if (b % 2 == 0)
                         * {
                         *  Array2D[b, k] = fibo[b / 2].ToString();
                         *  Array2D[jmlhBaris - 1 - b, k] = fibo[b / 2].ToString();
                         * }
                         * else
                         * {
                         *  Array2D[b, k] = ((char)(ascii + (b + 1) / 2)).ToString();
                         *  Array2D[b, jmlhKolom - 1 - k] = ((char)(ascii + (b + 1) / 2)).ToString();
                         * }*/
                    }
                    else if (b >= k && b + k <= JumlahKolom - 1)
                    {
                        Array2D[b, k] = k % 2 == 0 ? fibo[k / 2].ToString() : ((char)(ascii + (k + 1) / 2)).ToString();
                        Array2D[b, JumlahKolom - 1 - k] = k % 2 == 0 ? fibo[k / 2].ToString() : ((char)(ascii + (k + 1) / 2)).ToString();
                    }
                }
            }
        }
Example #7
0
        private void IsiArray()
        {
            int[] Fibo  = FunctionBase.Fibo(JumlahBaris * JumlahKolom);
            int[] Tribo = FunctionBase.Tribo(JumlahBaris * JumlahKolom);
            int   nilai = 0;

            for (int b = 0; b < JumlahBaris; b++)
            {
                int ascii = 65;
                for (int k = 0; k < JumlahKolom; k++)
                {
                    if (b + k >= JumlahBaris / 2 && k - b <= JumlahBaris / 2 && b < JumlahBaris / 2)
                    {
                        Array2D[b, k] = Fibo[nilai].ToString();
                        Array2D[JumlahBaris - 1 - b, k] = Tribo[nilai].ToString();
                        nilai++;
                    }
                    else if (b == JumlahBaris / 2 && k <= JumlahKolom / 2)
                    {
                        Array2D[b, k] = ((char)ascii).ToString();
                        Array2D[b, JumlahKolom - 1 - k] = ((char)ascii).ToString();
                        ascii++;
                    }
                }
            }
        }
Example #8
0
 private void IsiArray()
 {
     int[] Fibo  = FunctionBase.Fibo(JumlahKolom);
     int[] Tribo = FunctionBase.Tribo(JumlahKolom);
     for (int b = 0; b < JumlahBaris; b++)
     {
         for (int k = 0; k < JumlahKolom; k++)
         {
             if (b == k)
             {
                 Array2D[b, k] = Fibo[k].ToString();
                 Array2D[b, JumlahKolom - 1 - k] = Fibo[b].ToString();
             }
             else if (b + k == JumlahBaris - 1)
             {
                 Array2D[b, k] = Tribo[k].ToString();
                 Array2D[b, JumlahKolom - 1 - k] = Tribo[b].ToString();
             }
             else if (b >= k && b + k <= JumlahBaris - 1 && b - k != 1 && b + k != JumlahBaris - 2)
             {
                 Array2D[b, k] = "A";
                 Array2D[b, JumlahKolom - 1 - k] = "A";
             }
         }
     }
 }
Example #9
0
        private void IsiArray()
        {
            int[] Fibo  = FunctionBase.Fibo(JumlahBaris * JumlahBaris);
            int   angka = 0;

            for (int b = 0; b < JumlahBaris; b++)
            {
                for (int k = 0; k < JumlahKolom; k++)
                {
                    if (b + k >= JumlahBaris - 1 && k - b <= JumlahBaris - 1)
                    {
                        Array2D[b, k] = Fibo[angka++].ToString();
                    }
                }
            }
        }
Example #10
0
        private void IsiArray()
        {
            //Console.WriteLine("Nilai Jumlah Baris: {0}", jumlahBaris);
            //Console.WriteLine("Nilai Jumlah Kolom: {0}", JumlahKolom);
            //Console.WriteLine("Buffer Array: {0}", jumlahBaris * JumlahKolom);

            int[] Fibo = FunctionBase.Fibo(JumlahKolom);
            for (int b = 0; b < JumlahBaris; b++)
            {
                for (int k = 0; k < JumlahKolom; k++)
                {
                    Array2D[0, k] = Fibo[k].ToString();
                    //diagonal kiri ke kanan
                    //if (b == k)
                    //Array2D[b, k] = (k * 2 + 1).ToString();
                    //diagonal kanan ke kiri
                    //else if (b + k == jumlahBaris - 1)
                    //Array2D[b, k] = (k * 2).ToString();
                }
            }
        }
Example #11
0
        private void IsiArray()
        {
            int[] Fibo = FunctionBase.Fibo(JumlahBaris);

            for (int b = 0; b < JumlahBaris; b++)
            {
                for (int k = 0; k < JumlahKolom; k++)
                {
                    if (b <= k && b + k <= JumlahBaris - 1 && b % 2 == 0)
                    {
                        Array2D[b, k] = Fibo[b / 2].ToString();
                        Array2D[JumlahBaris - 1 - b, k] = Fibo[b / 2].ToString();
                    }
                    else if (b >= k && b + k <= JumlahBaris - 1 && k % 2 == 0)
                    {
                        Array2D[b, k] = Fibo[k / 2].ToString();
                        Array2D[b, JumlahKolom - 1 - k] = Fibo[k / 2].ToString();
                    }
                }
            }
        }
Example #12
0
 private void isiArray(int n)
 {
     int[] fibo = FunctionBase.Fibo(n * n);
     for (int bangun = 0; bangun < n; bangun++)
     {
         int StarBar = (bangun * bangun + bangun) / 2 + (n - bangun) * bangun;
         int StarKol = (n - 1 - bangun) * (n - 1 - bangun);
         int angka   = 0;
         int endBar  = StarBar + (n - 1 - bangun);
         int endKol  = StarKol + ((n - 1 - bangun) * 2);
         for (int b = StarBar; b <= endBar; b++)
         {
             for (int k = StarKol; k <= endKol; k++)
             {
                 if (b + k >= StarKol + endBar && k + endBar <= b + endKol)
                 {
                     Array2D[b, k] = fibo[angka++].ToString();
                 }
             }
         }
     }
 }
Example #13
0
        private void IsiArray(int n)
        {
            int ganjil = 1;

            int[] Fibo  = FunctionBase.Fibo(JumlahBaris * JumlahBaris);
            int[] Tribo = FunctionBase.Tribo(JumlahBaris * JumlahBaris);
            int   fb    = 0;
            int   tb    = 0;

            for (int b = 0; b < JumlahBaris; b++)
            {
                for (int k = 0; k < JumlahKolom; k++)
                {
                    //atas
                    if (b + k >= n * 2 - 1 && k - b <= n * 2 - 1 && b <= n - 1)
                    {
                        Array2D[b, k] = ganjil.ToString();
                        ganjil       += 2;
                    }
                    else if (b - k <= n * 2 - 1 && b + k <= (n * 2 - 1) + (n * 3) + n - 2 && b >= JumlahBaris - n)
                    {
                        Array2D[b, k] = ganjil.ToString();
                        ganjil       += 2;
                    }
                    //kiri
                    else if (b + k >= n * 2 - 1 && b - k <= n * 2 - 1 && k <= n - 1)
                    {
                        Array2D[b, k] = Fibo[fb++].ToString();
                    }
                    //kanan
                    else if (k - b <= n * 2 - 1 && b + k <= (n * 2 - 1) + (n * 3) + n - 2 && k >= JumlahKolom - n)
                    {
                        Array2D[b, k] = Tribo[tb++].ToString();
                    }
                }
            }
        }
Example #14
0
        private void IsiArray(int n)
        {
            for (int bangun = 0; bangun < n; bangun++)
            {
                int[] Fibo   = FunctionBase.Fibo(JumlahKolom * n);
                int   index  = 0;
                int   ganjil = 1;
                //Starting point
                int StarBar = (bangun * bangun + bangun) / 2;
                int StarKol = (n * 2 - 1) / 2 - bangun;

                //Ending Point
                int EndBar = StarBar + bangun;
                int EndKol = StarKol + (bangun * 2);


                for (int b = StarBar; b <= EndBar; b++)
                {
                    for (int k = StarKol; k <= EndKol; k++)
                    {
                        if (b - k >= EndBar - EndKol && b + k >= EndBar + StarKol)
                        {
                            if (bangun % 2 == 0)
                            {
                                Array2D[b, k] = ganjil.ToString();
                                ganjil       += 2;
                            }
                            else
                            {
                                Array2D[b, k] = Fibo[index++].ToString();
                            }
                        }
                    }
                }
            }
        }