I have just take the format and spacing but can any one tell me a single change to get the values which print in actual pascal triangle program in java...
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package patterns;
/**
*
* @author Love Poet
*/
public class p11 {
public static void main(String args[]) {
int row, col, count = 0;
for (row = 1; row <= 5; row++) {
for (col = 1; col <= 9; col++) {
if (((row + col) % 2 == 0) && (row + col >= 6)) {
System.out.print("* ");
count++;
} else if (count == row) {
break;
} else {
System.out.print(" ");
}
}
count = 0;
System.out.println();
}
}
}
My Output:
*
* *
* * *
* * * *
* * * * *
What I want:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1