private void isiArray(int n) { int[] fibo = FunctionBase.FibonacciSoal01(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++].ToString(); } else if (b == eBaris || k == sKolom) { Array2D[b, k] = fibo[nAngka--].ToString(); } } } } } } }
private void IsiArray() { int[] fibo = FunctionBase.FibonacciSoal01(JmlhBaris); for (int b = 0; b < JmlhBaris; b++) { for (int k = 0; k < JmlhKolom; k++) { //Atas if (b <= k && b + k <= JmlhBaris - 1) { //Segitiga atas Array2D[b, k] = fibo[b].ToString(); //Segitiga bawah - MIRROR Array2D[JmlhBaris - 1 - b, k] = fibo[b].ToString(); } //Kiri else if (b >= k && b + k <= JmlhBaris - 1) { //Segitiga kiri Array2D[b, k] = fibo[k].ToString(); //Segitiga kanan - MIRROR Array2D[b, JmlhKolom - 1 - k] = fibo[k].ToString(); } } } }
private void IsiArray() { int ascii = 65; int[] fibo = FunctionBase.FibonacciSoal01(JmlhBaris); for (int b = 0; b < JmlhBaris; b++) { for (int k = 0; k < JmlhKolom; k++) { if (b == k) { Array2D[b, k] = fibo[b].ToString(); Array2D[b, JmlhKolom - k - 1] = fibo[b].ToString(); } else if (b == JmlhBaris / 2 && k <= JmlhKolom / 2) { Array2D[b, k] = ((char)ascii).ToString(); Array2D[b, JmlhKolom - k - 1] = ((char)ascii).ToString(); ascii++; } else if (b + k == (JmlhKolom - 1) / 2) { Array2D[b, k] = fibo[k].ToString(); Array2D[b, JmlhKolom - k - 1] = fibo[k].ToString(); } } } }
private void IsiArray(int n) { int[] fibo = FunctionBase.FibonacciSoal01(JmlhKolom * JmlhKolom); for (int bangun = 0; bangun < n; bangun++) { int StrBaris = n * bangun; int StrKolom = bangun % 2 * (n * 2 - 1); int EndBaris = StrBaris + n - 1; int EndKolom = StrKolom + 2 * (n - 1); int angka = 0; int ganjil = 1; for (int b = StrBaris; b <= EndBaris; b++) { for (int k = StrKolom; k <= EndKolom; k++) { if (b + k >= StrKolom + EndBaris && k + EndBaris <= b + EndKolom) { if (bangun % 2 == 0) { Array2D[b, k] = fibo[angka++].ToString(); } else { Array2D[b, k] = ganjil.ToString(); ganjil += 2; } } } } } }
private void IsiArray() { int[] fibo = FunctionBase.FibonacciSoal01(JmlhBaris); int ascii = 64; for (int b = 0; b < JmlhBaris; b++) { for (int k = 0; k < JmlhKolom; k++) { //Atas if (b <= k && b + k <= JmlhBaris - 1 && b % 2 == 0) { //Segitiga atas Array2D[b, k] = fibo[b / 2].ToString(); //Segitiga bawah - MIRROR Array2D[JmlhBaris - 1 - b, k] = fibo[b / 2].ToString(); } else { //else segitiga atas Array2D[b, k] = ((char)(ascii + (b + 1) / 2)).ToString(); //else segitiga bawah - MIRROR Array2D[JmlhBaris - 1 - b, k] = ((char)(ascii + (b + 1) / 2)).ToString(); } } } }
private void IsiArray() { int[] fibo = FunctionBase.FibonacciSoal01(JmlhBaris); for (int b = 0; b < JmlhBaris; b++) { for (int k = 0; k < JmlhKolom; k++) { if (b == k || b + k == JmlhKolom - 1) { Array2D[b, k] = fibo[k].ToString(); } else if (b < k && b + k < JmlhKolom - 1) { Array2D[b, k] = "A"; } else if (b < k && b + k > JmlhKolom - 1) { Array2D[b, k] = "B"; } else if (b > k && b + k > JmlhKolom - 1) { Array2D[b, k] = "C"; } else { Array2D[b, k] = "D"; } } } }
private void IsiArray() { int[] fibo = FunctionBase.FibonacciSoal01(JmlhBaris); //fibonacci 1 dimensi = fibonaccisoal01(JmlhBaris) for (int b = 0; b < JmlhBaris; b++) //agar di array muncul baris { for (int k = 0; k < JmlhKolom; k++) //agar di array muncul kolom { //Atas if (b <= k && b + k <= JmlhBaris - 1 && b % 2 == 0) //segitiga atas && modulus 2 sisa 0 (agar ada sela baris) { //segitiga atas Array2D[b, k] = fibo[b / 2].ToString(); //fibo[b / 2] = agar penempatan bil. fibonaci sesuai sela baris //segitiga bawah - MIRROR Array2D[JmlhBaris - 1 - b, k] = fibo[b / 2].ToString(); } //Kiri else if (b >= k && b + k <= JmlhBaris - 1 && k % 2 == 0) //segitiga kiri && modulus 2 sisa 0 (agar ada sela kolom) { //segitiga kiri Array2D[b, k] = fibo[k / 2].ToString(); //fibo[b / 2] = (index ke-) agar penempatan bil. fibonaci sesuai sela kolom //segitiga kanan - MIRROR Array2D[b, JmlhKolom - 1 - k] = fibo[k / 2].ToString(); } } } }
private void isiArray(int n) { int[] fibo = FunctionBase.FibonacciSoal01(n * n); for (int bangun = 0; bangun < n; bangun++) { int StarBaris = (bangun * bangun + bangun) / 2 + (n - bangun) * bangun; int StarKolom = (n - 1 - bangun) * (n - 1 - bangun); int angka = 0; int EndBaris = StarBaris + (n - 1 - bangun); int EndKolom = StarKolom + ((n - 1 - bangun) * 2); for (int b = StarBaris; b <= EndBaris; b++) { for (int k = StarKolom; k <= EndKolom; k++) { if (b + k >= StarKolom + EndBaris && k + EndBaris <= b + EndKolom) { Array2D[b, k] = fibo[angka++].ToString(); } } } } }
private void IsiArray() { //Console.WriteLine("Nilai Jumlah Baris : {0}", JmlhBaris); //Console.WriteLine("Nilai Jumlah Kolom : {0}", JmlhKolom); //Console.WriteLine("Buffer Array : {0}", JmlhBaris * JmlhKolom); //for (int b = 0; b < JmlhBaris; b++) { for (int k = 0; k < JmlhKolom; k++) { int[] Fibo = FunctionBase.FibonacciSoal01(JmlhKolom); { Array2D[0, k] = Fibo[k].ToString(); } ////diagonal kiri atas //if (b == k) // Array2D[b, k] = (k * 2 + 1).ToString(); ////diagonal kiri bawah //else if (b + k == JmlhBaris - 1) // Array2D[b, k] = (k * 2).ToString(); } } }
private void IsiArray(int n) { int[] fibo = FunctionBase.FibonacciSoal01(JmlhKolom * JmlhKolom); int[] tribo = FunctionBase.FibonacciSoal02(JmlhKolom * JmlhKolom); int angka = 1; int index1 = 0; int index2 = 0; for (int b = 0; b < JmlhBaris; b++) { for (int k = 0; k < JmlhKolom; k++) { //segitiga atas if (b + k >= n * 2 - 1 && k - b <= n * 2 - 1 && b <= n - 1) { Array2D[b, k] = angka.ToString(); angka += 2; } //segitiga kiri if (b + k >= n * 2 - 1 && b - k <= n * 2 - 1 && k <= n - 1) { Array2D[b, k] = fibo[index1++].ToString(); } //segitiga bawah if (b - k <= n * 2 - 1 && b + k <= (n * 2 - 1) + (n * 3) + n - 2 && b >= JmlhBaris - n) { Array2D[b, k] = angka.ToString(); angka += 2; } if (k - b <= n * 2 - 1 && b + k <= (n * 2 - 1) + (n * 3) + n - 2 && k >= JmlhKolom - n) { Array2D[b, k] = tribo[index2++].ToString(); } } } }
private void IsiArray(int n) { for (int bangun = 0; bangun < n; bangun++) { int[] Fibo = FunctionBase.FibonacciSoal01(JmlhKolom * n); int index = 0; int ganjil = 1; //Starting point int StrBaris = (bangun * bangun + bangun) / 2; int StrKolom = (n * 2 - 1) / 2 - bangun; //Ending Point int EndBaris = StrBaris + bangun; int EndKolom = StrKolom + (bangun * 2); for (int b = StrBaris; b <= EndBaris; b++) { for (int k = StrKolom; k <= EndKolom; k++) { if (b + k >= StrKolom + EndBaris && k + EndBaris <= b + EndKolom) { if (bangun % 2 == 0) { Array2D[b, k] = ganjil.ToString(); ganjil += 2; } else { Array2D[b, k] = Fibo[index++].ToString(); } } } } } }