All pastes #798719 Raw Edit

Christian Hartwell

public java v1 · immutable
#798719 ·published 2007-11-26 23:33 UTC
rendered paste body
import java.util.*;public class Pascal{    public static void main(String args[]){        Scanner reader = new Scanner(System.in);        int ragged[][] = new int [10][];        int userRows=0;                System.out.println("Enter the number of rows");        userRows=reader.nextInt();                for(int x=0;x<userRows;x++)        {            for(int y=0;y<=x;y++)            {                ragged[x] = new int [y+1];            }        }        for(int x=0;x<userRows;x++)        {            for(int y=0;y<ragged[x].length;y++)            {                if(y==0||y==x)                    ragged[x][y]=1;                else                    ragged[x][y]=ragged[x-1][y]+ragged[x-1][y-1];            }        }                System.out.println("Here is your triangle");        for(int x=0; x<userRows;x++)        {            for(int y=userRows;y>x;y--)            {                System.out.print("\t\t");            }                        for(int z=0;z<ragged[x].length;z++)            {                System.out.print(ragged[x][z]+"\t\t");            }            System.out.print("\n");        }    }}