示例#1
0
文件: soal03.cs 项目: rifkial/PRrifki
        private void IsiArray(int n)
        {
            int[] fibo  = FunctionBase.Fibonacci(n * n * 2);
            int[] tribo = FunctionBase.Tribonacci(n * n * 2);
            int   tb    = 0;
            int   fb    = 0;

            for (int bgn = 0; bgn < n; bgn++)
            {
                int stBrs  = n * bgn;
                int stKol  = bgn % 2 * (n * 2 - 1);
                int endBrs = stBrs + (n - 1);
                int endKol = stKol + 2 * (n - 1);

                for (int b = stBrs; b <= endBrs; b++)
                {
                    for (int k = stKol; k <= endKol; k++)
                    {
                        if (b + k >= stKol + endBrs && k + endBrs <= b + endKol)
                        {
                            Array2D[b, k] = fibo[fb++].ToString();
                        }

                        else if (b + k >= stKol + endBrs && k + endBrs <= b + endKol)
                        {
                            Array2D[b, k] = tribo[tb++].ToString();
                        }
                    }
                }
            }
        }
示例#2
0
 private void IsiArray2D(int n)
 {
     for (int bgn = 0; bgn < n; bgn++)
     {
         //starting point
         int stbrs = (bgn * bgn + bgn) / 2;
         int stklm = (n * 2 - 1) / 2 - bgn;
         //ending point
         int   endbrs = stbrs + bgn;
         int   endklm = stklm + (bgn * 2);
         int   angka  = 1;
         int   a      = 0;
         int[] fibo   = FunctionBase.Fibonacci(jumlahbaris * jumlahkolom);
         for (int b = stbrs; b <= endbrs; b++)
         {
             for (int k = stklm; k <= endklm; k++)
             {
                 if (b + k >= stklm + endbrs && k + endbrs <= b + endklm && bgn % 2 == 0)
                 {
                     Array2D[b, k] = angka.ToString();
                     angka        += 2;
                 }
                 else if (b + k >= stklm + endbrs && k + endbrs <= b + endklm && bgn % 2 == 1)
                 {
                     Array2D[b, k] = fibo[a++].ToString();
                 }
             }
         }
     }
 }
示例#3
0
文件: soal1.cs 项目: sulis96/PRSulis
        private void IsiArray()
        {
            int[] fibo = FunctionBase.Fibonacci(jumlahkolom);
            for (int k = 0; k < jumlahkolom; k++)
            {
                Array2D[0, k] = fibo[k].ToString();
            }
            //Console.WriteLine("nilai jumlah baris : {0}", jumlahbaris);
            //Console.WriteLine("nilai jumlah kolom : {0}", jumlahkolom);
            //Console.WriteLine("buffer Array : {0}", jumlahbaris*jumlahkolom);

            //for(int b = 0; b < jumlahbaris; b++)
            //{
            //    for(int k = 0; k < jumlahkolom; k++)
            //    {
            //        //diagonal kiri ganjil
            //        if (b == k)
            //        {
            //            Array2D[b, k] = (k * 2 + 1).ToString();
            //        }
            //        else if(b + k == jumlahbaris - 1)
            //        {
            //            Array2D[b, k] = (k * 2).ToString();
            //        }

            //    }
            //}
        }
示例#4
0
 private void IsiArray(int n)
 {
     int[] fibo = FunctionBase.Fibonacci((n * 2) + (n - 2) * 2);
     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;
                 int stBrs  = n * bb;
                 int stKlm  = n * bk;
                 int enBrs  = stBrs + n - 1;
                 int enKlm  = stKlm + n - 1;
                 for (int b = stBrs; b <= enBrs; b++)
                 {
                     for (int k = stKlm; k <= enKlm; k++)
                     {
                         if (b == stBrs || k == enKlm)
                         {
                             Array2D[b, k] = fibo[angka].ToString();
                             angka++;
                         }
                         else if (b == enBrs || k == stKlm)
                         {
                             Array2D[b, k] = fibo[nangka - 1].ToString();
                             nangka--;
                         }
                     }
                 }
             }
         }
     }
 }
示例#5
0
        private void isiArray(int n)
        {
            int[] fibo  = FunctionBase.Fibonacci(n * n);
            int[] tribo = FunctionBase.Tribonacci(n * n);
            int   angka = 0;
            int   ascii = 65;

            for (int b = 0; b < JmlBaris; b++)
            {
                for (int k = 0; k < JmlKolom; k++)
                {
                    if (b == JmlBaris / 2)
                    {
                        Array2D[b, k] = ((char)ascii).ToString();
                        if (k < JmlBaris / 2)
                        {
                            ascii++;
                        }
                        else
                        {
                            ascii--;
                        }
                        angka = 0;
                    }
                    else if (b + k >= JmlBaris / 2 && k - b <= JmlBaris / 2 && b < JmlBaris / 2)
                    {
                        Array2D[b, k] = fibo[angka++].ToString();
                    }
                    else if (b - k <= JmlBaris / 2 && b + k <= JmlKolom / 2 + JmlKolom - 1 && b > JmlBaris / 2)
                    {
                        Array2D[b, k] = tribo[angka++].ToString();
                    }
                }
            }
        }
示例#6
0
 private void isiArray()
 {
     int[] fibo = FunctionBase.Fibonacci(JmlKolom);
     for (int b = 0; b < JmlBaris; b++)
     {
         for (int k = 0; k < JmlKolom; k++)
         {
             if (b == k)
             {
                 Array2D[b, k] = fibo[b].ToString();
             }
             else if (b + k == JmlBaris - 1)
             {
                 Array2D[b, k] = fibo[k].ToString();
             }
             else if (b <= k && b + k <= JmlBaris - 1)
             {
                 Array2D[b, k] = "A";
             }
             else if (b >= k && b + k <= JmlKolom - 1)
             {
                 Array2D[b, k] = "D";
             }
             else if (b >= k && b + k >= JmlKolom - 1)
             {
                 Array2D[b, k] = "C";
             }
             else if (b <= k && b + k >= JmlKolom - 1)
             {
                 Array2D[b, k] = "B";
             }
         }
     }
 }
示例#7
0
        private void IsiArray(int m)
        {
            fibo = FunctionBase.Fibonacci(m * m);
            for (int bgn = 0; bgn < m; bgn++)
            {
                angka = 1;
                int stKol  = (m + 1) * bgn;
                int endKol = stKol + m - 1;

                //Bawah to Kanan
                for (int k = stKol; k <= endKol - 1; k++)
                {
                    Array2D[m - 1, k] = GetValue(angka++).ToString();
                }
                //Kanan to Atas
                for (int b = m - 1; b >= 1; b--)
                {
                    Array2D[b, endKol] = GetValue(angka++).ToString();
                }
                //Atas to Kiri
                for (int k = endKol; k >= stKol + 1; k--)
                {
                    Array2D[0, k] = GetValue(angka++).ToString();
                }
                //Atas to Bawah
                for (int b = 0; b <= m - 2; b++)
                {
                    Array2D[b, stKol] = GetValue(angka++).ToString();
                }
            }
        }
示例#8
0
        private void IsiArray(int n)
        {
            for (int bgn = 0; bgn < n; bgn++)
            {
                int[] fibo   = FunctionBase.Fibonacci(n * n);
                int[] tribo  = FunctionBase.Tribonacci(n * n);
                int   angka  = 0;
                int   stBrs  = n * (bgn % 2);
                int   stKol  = (n * 2 - 1) * bgn;
                int   endBrs = stBrs + n - 1;
                int   endKol = stKol + (n * 2 - 1) - 1;

                for (int b = stBrs; b <= endBrs; b++)
                {
                    for (int k = stKol; k <= endKol; k++)
                    {
                        if (b + k >= stKol + endBrs && k + endBrs <= b + endKol && bgn % 2 == 0)
                        {
                            Array2D[b, k] = fibo[angka++].ToString();
                        }
                        else if ((b - stBrs) <= (k - stKol) && (b - stBrs) + (k - stKol) <= endKol - stKol && bgn % 2 == 1)
                        {
                            Array2D[b, k] = tribo[angka++].ToString();
                        }
                    }
                }
            }
        }
示例#9
0
 private void isiArray(int n)
 {
     int[] fibo = FunctionBase.Fibonacci(n * n);
     for (int bgn = 0; bgn < n; bgn++)
     {
         int fb     = 0;
         int ganjil = 1;
         int stBrs  = n * bgn;
         int stKol  = bgn % 2 * (n * 2 - 1);
         int endBrs = stBrs + (n - 1);
         int endKol = stKol + 2 * (n - 1);
         for (int b = stBrs; b <= endBrs; b++)
         {
             for (int k = stKol; k <= endKol; k++)
             {
                 if (b + k >= stKol + endBrs && k + endBrs <= b + endKol)
                 {
                     if (bgn % 2 == 0)
                     {
                         Array2D[b, k] = fibo[fb++].ToString();
                     }
                     else
                     {
                         Array2D[b, k] = ganjil.ToString();
                         ganjil       += 2;
                     }
                 }
             }
         }
     }
 }
示例#10
0
 private void isiArray(int n)
 {
     int[] fibo = FunctionBase.Fibonacci(JmlKolom * n);
     for (int bgn = 0; bgn < n; bgn++)
     {
         int stBrs  = (bgn * bgn + bgn) / 2;
         int stKol  = ((n * 2 - 1) / 2) - bgn;
         int endBrs = stBrs + bgn;
         int endkol = stKol + (bgn * 2);
         int ganjil = 1;
         int angka  = 0;
         for (int b = stBrs; b <= endBrs; b++)
         {
             for (int k = stKol; k <= endkol; k++)
             {
                 if (b + k >= stKol + endBrs && k + endBrs <= b + endkol)
                 {
                     if (bgn % 2 == 0)
                     {
                         Array2D[b, k] = ganjil.ToString();
                         ganjil       += 2;
                     }
                     else
                     {
                         Array2D[b, k] = fibo[angka++].ToString();
                     }
                 }
             }
         }
     }
 }
示例#11
0
        private void IsiArray2D(int n)
        {
            int[] fibo = FunctionBase.Fibonacci(jumlahbaris * jumlahkolom);

            for (int bb = 0; bb < n; bb++)
            {
                for (int bk = 0; bk < n; bk++)
                {
                    if (bb == bk)
                    {
                        int angka  = 0;
                        int stbrs  = bb * n;
                        int stklm  = bk * n;
                        int endbrs = stbrs + n - 1;
                        int endklm = stklm + n - 1;

                        for (int b = stbrs; b <= endbrs; b++)
                        {
                            for (int k = stklm; k <= endklm; k++)
                            {
                                if (b == stbrs || k == endklm)
                                {
                                    Array2D[b, k] = fibo[angka].ToString();
                                    angka++;
                                }
                                else if (k == stklm || b == endbrs)
                                {
                                    Array2D[b, k] = fibo[(jumlahbaris - (b - stbrs) - (k - stklm))].ToString();
                                }
                            }
                        }
                    }
                }
            }
        }
示例#12
0
        private void IsiArray(int n)
        {
            int[] fibo = FunctionBase.Fibonacci(JmlhBaris * JmlhKolom);
            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 StBaris  = bb * n;
                        int StKolom  = bk * n;
                        int EndBaris = StBaris + n - 1;
                        int EndKolom = StKolom + n - 1;

                        for (int b = StBaris; b <= EndBaris; b++)
                        {
                            for (int k = StKolom; k <= EndKolom; k++)
                            {
                                if (b == StBaris || k == EndKolom)
                                {
                                    Array2D[b, k] = fibo[angka++].ToString();
                                }
                                else if (b == EndBaris || k == StKolom)
                                {
                                    Array2D[b, k] = fibo[nAngka--].ToString();
                                }
                            }
                        }
                    }
                }
            }
        }
示例#13
0
        private void IsiArray(int n)
        {
            int[] fibo  = FunctionBase.Fibonacci(n * n * 2);
            int[] tribo = FunctionBase.Tribonacci(n * n * 2);
            int   fb    = 0;
            int   tb    = 0;

            for (int bgn = 0; bgn < n; bgn++)
            {
                int stBrs  = jmlBaris - 1 - (bgn * bgn + bgn) / 2 - bgn;
                int stKol  = jmlKolom - 1 - (bgn * bgn) - bgn * 2;
                int endBrs = stBrs + bgn;
                int endKol = stKol + bgn * 2;

                for (int b = stBrs; b <= endBrs; b++)
                {
                    for (int k = stKol; k <= endKol; k++)
                    {
                        if (b - stBrs <= k - stKol && (b - stBrs) + (k - stKol) <= endKol - stKol)
                        {
                            Array2D[b, k] = bgn % 2 == 0 ? tribo[tb++].ToString() : fibo[fb++].ToString();
                        }
                    }
                }
            }
        }
示例#14
0
 private void IsiArray(int n)
 {
     int[] fibo = FunctionBase.Fibonacci(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 stBrs  = bb * n;
                 int stKol  = bk * n;
                 int endBrs = stBrs + n - 1;
                 int endKol = stKol + n - 1;
                 for (int b = stBrs; b <= endBrs; b++)
                 {
                     for (int k = stKol; k <= endKol; k++)
                     {
                         if (b == stBrs || k == endKol)
                         {
                             Array2D[b, k] = fibo[angka++].ToString();
                         }
                         else if (b == endBrs || k == stKol)
                         {
                             Array2D[b, k] = fibo[nAngka--].ToString();
                         }
                     }
                 }
             }
         }
     }
 }
示例#15
0
        private void IsiArray2D(int n)
        {
            int  a     = 0;
            bool kanan = true;

            int[] fibo = FunctionBase.Fibonacci(jumlahbaris * jumlahkolom);
            //baris
            for (int b = 0; b < n; b++)
            {
                //kolom
                for (int k = 0; k < n; k++)
                {
                    if (kanan)
                    {
                        if (b % 2 == 0)
                        {
                            Array2D[b, k] = fibo[a++].ToString();
                        }
                        else
                        {
                            Array2D[b, n - 1] = fibo[a++].ToString();
                        }
                    }
                    //else if (b % 2 == 0)
                    //{
                    //    Array2D[b, n - 1 - k] = fibo[a++].ToString();
                    //}
                    //else
                    //    Array2D[b, 0] = fibo[a++].ToString();
                }
                kanan = !kanan;
                Console.WriteLine();
            }
        }
示例#16
0
        private void isiArray(int n)
        {
            int[] fibo   = FunctionBase.Fibonacci(JmlKolom);
            int[] tribo  = FunctionBase.Tribonacci(JmlKolom);
            int   angka1 = 1;
            int   angka2 = 1;

            for (int b = 0; b < JmlBaris; b++)
            {
                for (int k = 0; k < JmlKolom; k++)
                {
                    if (b == k)
                    {
                        Array2D[b, k] = fibo[b].ToString();
                        Array2D[b, JmlKolom - 1 - k] = fibo[b].ToString();
                    }
                    else if (b + k == JmlBaris - 1)
                    {
                        Array2D[b, k] = tribo[k].ToString();
                        Array2D[b, JmlKolom - 1 - k] = tribo[k].ToString();
                    }
                    else if (b >= k && b + k <= JmlBaris - 1 && b - k != 1 && b + k != JmlBaris - 2)
                    {
                        Array2D[b, k] = "A";
                        Array2D[b, JmlKolom - 1 - k] = "A";
                    }
                }
            }
        }
示例#17
0
 private void isiArray(int n)
 {
     int[] fibo = FunctionBase.Fibonacci(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--];
                         }
                     }
                 }
             }
         }
     }
 }
示例#18
0
        private void isiArray(int n)
        {
            int[] fibo   = FunctionBase.Fibonacci(JmlKolom * n);
            int[] tribo  = FunctionBase.Tribonacci(JmlKolom * n);
            int   angka1 = 0;
            int   angka2 = 0;

            for (int bgn = 0; bgn < n; bgn++)
            {
                int stBrs  = (bgn * bgn + bgn) / 2;
                int stKol  = ((n * 2 - 1) / 2) - bgn;
                int endBrs = stBrs + bgn;
                int endkol = stKol + (bgn * 2);
                for (int b = stBrs; b <= endBrs; b++)
                {
                    for (int k = stKol; k <= endkol; k++)
                    {
                        if (b + k == stKol + endBrs || k + endBrs == b + endkol || b == endBrs)
                        {
                            if (bgn % 2 == 0)
                            {
                                Array2D[b, k] = fibo[angka1++].ToString();
                            }
                            else
                            {
                                Array2D[b, k] = tribo[angka2++].ToString();
                            }
                        }
                    }
                }
            }
        }
示例#19
0
        private void IsiArray2D(int n)
        {
            for (int bgn = 0; bgn < n; bgn++)
            {
                int[] fibo = FunctionBase.Fibonacci(jumlahkolom * jumlahbaris);
                //starting point
                int stbrs = (jumlahbaris - 1) - (bgn * bgn - 3 * bgn) / 2;
                int stklm = (jumlahkolom - 1) - (bgn * bgn + 2 * bgn);
                int a     = 0;

                //ending point
                int endbrs = stbrs + bgn;
                int endklm = stklm + (bgn * 2);
                for (int b = stbrs; b <= endbrs; b++)
                {
                    for (int k = stklm; k <= endklm; k++)
                    {
                        if (b + k >= endklm - endbrs + 2 * stbrs && k - b <= endklm - endbrs)
                        {
                            Array2D[b, k] = fibo[a++].ToString();
                        }
                    }
                }
            }
        }
示例#20
0
文件: soal09.cs 项目: rifkial/PRrifki
        private void IsiArray()
        {
            int[] fibo = FunctionBase.Fibonacci(JmlBaris / 2);

            for (int b = 0; b < JmlBaris; b++)
            {
                for (int k = 0; k < JmlKolom; k++)
                {
                    //atas
                    if (b <= k && b + k <= JmlBaris - 1 && b % 2 == 0)
                    {
                        //Garis bawah
                        Array2D[b, k] = fibo[b / 2].ToString();
                        //GARIS BAWAH - MIRROR
                        Array2D[JmlBaris - 1 - b, k] = fibo[b / 2].ToString();
                    }
                    //kiri
                    else if (b >= k && b + k <= JmlBaris - 1 && k % 2 == 0)
                    {
                        //Garis bawah
                        Array2D[b, k] = fibo[k / 2].ToString();
                        //GARIS BAWAH - MIRROR
                        Array2D[b, JmlKolom - 1 - k] = fibo[k / 2].ToString();
                    }
                }
            }
        }
示例#21
0
        private void isiArray(int n)
        {
            int[] fibo  = FunctionBase.Fibonacci(JmlKolom * n + (n - 1));
            int   angka = 0;
            bool  kanan = true;

            for (int b = 0; b < JmlBaris; b++)
            {
                for (int k = 0; k < JmlKolom; k++)
                {
                    if (b % 2 == 0)
                    {
                        Array2D[b, kanan ? k : JmlKolom - 1 - k] = fibo[angka++].ToString();
                    }
                    else if (b % 2 == 1)
                    {
                        Array2D[b, kanan ? JmlKolom - 1 : 0] = fibo[angka].ToString();
                    }
                }
                if (b % 2 == 1)
                {
                    angka++;
                    kanan = !kanan;
                }
            }
        }
示例#22
0
 private void isiArray()
 {
     int[] fibo = FunctionBase.Fibonacci(JmlKolom);
     for (int k = 0; k < JmlKolom; k++)
     {
         Array2D[0, k] = fibo[k].ToString();
     }
 }
示例#23
0
文件: soal01.cs 项目: rifkial/PRrifki
        private void IsiArray(int n)
        {
            int[] fibo = FunctionBase.Fibonacci(n);

            for (int k = 0; k < jmlKolom; k++)
            {
                Array2D[0, k] = fibo[k].ToString();
                Array2D[1, k] = GetValue(k + 1, fibo[k]);
            }
        }
示例#24
0
 private void IsiArray()
 {
     int[] fibo = FunctionBase.Fibonacci(jumlahkolom);
     for (int k = 0; k < jumlahkolom; k++)
     {
         Array2D[0, k] = fibo[k].ToString();
         for (int b = 0; b < jumlahbaris; b++)
         {
             Array2D[b, k] = fibo[k].ToString();
         }
     }
 }
示例#25
0
        private void isiArray(int n)
        {
            int[] fibo  = FunctionBase.Fibonacci(n * n);
            int   angka = 0;

            for (int b = 0; b < JmlBaris; b++)
            {
                for (int k = 0; k < JmlKolom; k++)
                {
                    if (b + k >= JmlBaris - 1 && k - b <= JmlBaris - 1)
                    {
                        Array2D[b, k] = fibo[angka++].ToString();
                    }
                }
            }
        }
示例#26
0
        private void isiArray()
        {
            int[] fibo  = FunctionBase.Fibonacci(JmlBaris / 2);
            int   ascii = 64;

            for (int b = 0; b < JmlBaris; b++)
            {
                for (int k = 0; k < JmlKolom; k++)
                {
                    //atas
                    if (b <= k && b + k <= JmlBaris - 1)
                    {
                        //if (b % 2 == 0)
                        //{
                        //    Array2D[b, k] = fibo[b / 2].ToString();
                        //    Array2D[JmlBaris - 1 - b, k] = fibo[b / 2].ToString();
                        //}
                        //else
                        //{
                        //    Array2D[b, k] = ((char)(ascii + (b + 1) / 2)).ToString();
                        //    Array2D[JmlBaris - 1 - b, k] = ((char)(ascii + (b + 1) / 2)).ToString();
                        //}
                        Array2D[b, k] =
                            b % 2 == 0 ? fibo[b / 2].ToString() :
                            ((char)(ascii + (b + 1) / 2)).ToString();
                        //mirror
                        Array2D[JmlBaris - 1 - b, k] =
                            b % 2 == 0 ? fibo[b / 2].ToString() :
                            ((char)(ascii + (b + 1) / 2)).ToString();
                    }
                    //kiri
                    else if (b >= k && b + k <= JmlBaris - 1)
                    {
                        //Array2D[b, k] = fibo[k / 2].ToString();
                        //Array2D[b, JmlKolom - 1 - k] = fibo[k / 2].ToString();
                        Array2D[b, k] =
                            k % 2 == 0 ? fibo[k / 2].ToString() :
                            ((char)(ascii + (k + 1) / 2)).ToString();
                        //mirror
                        Array2D[b, JmlKolom - 1 - k] =
                            k % 2 == 0 ? fibo[k / 2].ToString() :
                            ((char)(ascii + (k + 1) / 2)).ToString();
                    }
                }
            }
        }
示例#27
0
        private void IsiArray(int n)
        {
            int ganjil = 1;

            int[] fibo   = FunctionBase.Fibonacci(jmlKolom * jmlBaris);
            int[] tribo  = FunctionBase.Tribonacci(jmlKolom * jmlBaris);
            int   index1 = 0;
            int   index2 = 0;

            for (int b = 0; b < jmlBaris; b++)
            {
                for (int k = 0; k < jmlKolom; k++)
                {
                    //atas
                    if (b + k >= n * 2 - 1 && k - b <= n * 2 - 1 && b <= n - 1)
                    {
                        Array2D[b, k] = ganjil.ToString();
                        ganjil       += 2;
                    }
                    //bawah
                    else if (b - k <= n * 2 - 1 && b + k <= (n * 2 - 1) + (n * 3) + n - 2 && b >= jmlBaris - 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[index1++].ToString();
                    }
                    //kanan
                    else if (k - b <= n * 2 - 1 && b + k <= (n * 2 - 1) + (n * 3) + n - 2 && k >= jmlKolom - n)
                    {
                        Array2D[b, k] = tribo[index2++].ToString();
                    }
                    else if (b == jmlBaris / 2 || k == jmlKolom / 2)
                    {
                        Array2D[b, k] = "X";
                    }
                }
            }
        }
示例#28
0
 private void isiArray()
 {
     int[] fibo = FunctionBase.Fibonacci(JmlKolom / 2);
     for (int b = 0; b < JmlBaris; b++)
     {
         for (int k = 0; k < JmlKolom; k++)
         {
             if (b <= k && b + k <= JmlBaris - 1 && b % 2 == 0)
             {
                 Array2D[b, k] = (b + 1).ToString();
                 Array2D[JmlBaris - 1 - b, k] = (b + 1).ToString();
             }
             else if (b >= k && b + k <= JmlBaris - 1 && k % 2 == 0)
             {
                 Array2D[b, k] = (k + 1).ToString();
                 Array2D[b, JmlKolom - 1 - k] = (k + 1).ToString();
             }
         }
     }
 }
示例#29
0
 private void isiArray()
 {
     int[] fibo = FunctionBase.Fibonacci(JmlBaris);
     for (int b = 0; b < JmlBaris; b++)
     {
         for (int k = 0; k < JmlKolom; k++)
         {
             if (b <= k && b + k <= JmlBaris - 1)
             {
                 Array2D[b, k] = fibo[b].ToString();
                 Array2D[JmlBaris - 1 - b, k] = fibo[b].ToString();
             }
             else if (b >= k && b + k <= JmlBaris - 1)
             {
                 Array2D[b, k] = fibo[k].ToString();
                 Array2D[b, JmlKolom - 1 - k] = fibo[k].ToString();
             }
         }
     }
 }
示例#30
0
文件: soal10.cs 项目: rifkial/PRrifki
        private void IsiArray(int n)
        {
            //value
            //int ganjil = 1;
            //int genap = 2;
            int[] fibo = FunctionBase.Fibonacci(jmlBaris * n);
            for (int bgn = 0; bgn < n; bgn++)
            {
                //starting point
                int stBrs = (bgn * bgn + bgn) / 2;
                int stKol = ((n * 2 - 1) / 2) - bgn;

                //ending point
                int endBrs = stBrs + bgn;
                int endKol = stKol + (bgn * 2);
                int angka  = 1;
                for (int b = stBrs; b <= endBrs; b++)
                {
                    for (int k = stKol; k <= endKol; k++)
                    {
                        if (b + k >= stKol + endBrs && k + endBrs <= b + endKol)
                        {
                            //Array2D[b, k] = angka++.ToString();
                            if (bgn % 2 == 0)
                            {
                                Array2D[b, k] = angka.ToString();
                                angka        += 2;
                            }
                            else
                            {
                                Array2D[b, k] = fibo[angka - 1].ToString();
                                angka++;
                            }
                        }
                        //    Array2D[b, k] = bgn % 2 == 0 ? angka++.ToString() : angka--.ToString();
                        //if (bgn % 2 == 0) ganjil += 2; else genap += 2;
                    }
                }
            }
        }