JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
Create a program which will make a Pascal's triangle 1>Using Arrays 2>Without using Arrays
Version 1 using an array
*/
import java.util.*;
public class BillPascal1{
public static void main(String[] args){
Scanner Scn = new Scanner(System.in);
int mn = Scn.nextInt() + 1;
if(mn>12){
System.out.println("The neatness of the format fails after 12.");
}
int cs[] = new int[mn+1]; // array length initialised with a variable expression.
cs[0] = 1;
cs[1] = 0;
for(int n=0; n<mn; n++){
System.out.format("%n");
for(int i=mn-n; i>0; i--){
System.out.format("%2s", "");
}
System.out.format("1");
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run