Chaekyunx’s Weblog “simple informatics cabin”

“q tau kesalahanq”

Posted on: November 5, 2008

ehya,.ternyata kmaren program penampil bulangan pascal pake array masih ada yang salah,..kan masih muncul 000000,..

nah,.ini baru sempet nyari gmana yg bener,…

source code bilangan pascal di java,..

import javax.swing.*;

public class PASCALARRAY {

public static void main(String args[])

{

int i;

int j;

int n;

int pascal[][];

pascal = new int [100][100];

String masukkan;

String keluaran=”Segitiga Pascal Array\n\n”;

masukkan = JOptionPane.showInputDialog(”Inputkan bilangan asli : “);

n=Integer.parseInt(masukkan);

for (i=0;i<n;i++)

{

for (j=0;j<n;j++)

{

if (j==0||i==j)

{

pascal[i][j]=1;

}

else if (i>j)

{

pascal [i][j]=pascal[i-1][j-1]+pascal[i-1][j];

}

else

{

pascal[i][j]=\n;

}

}

}

for (int baris=0;baris<n;baris++)

{

for(int kolom=0;kolom<=baris;kolom++)

keluaran += pascal [baris][kolom]+”\t”;

keluaran = keluaran + “\n\n”;

}

JTextArea outputArea = new JTextArea ();

outputArea.setText(keluaran);

JOptionPane.showMessageDialog(null, outputArea, “Segitiga Pascal Array”,JOptionPane.DEFAULT_OPTION);

System.exit(0);

}

}

nah,.ini inyaAllah bener,…

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: