Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String[][] pasc = new String[10][10] ;
- for(int i = 0 ; i < 10; i++) {
- for(int k = 0; k < 10; k++)
- pasc[i][k] = " " ;
- }
- for(int i = 0 ; i < 10; i++) {
- for(int k = 0; k <= i; k++)
- pasc[i][k] = "1" ;
- }
- String[][] pasc2 = new String[10][10];
- pasc2 = pasc ;
- for(int i = 2; i < 10; i++) {
- for(int k = 1; k < i; k++)
- pasc2[i][k] = String.valueOf(Integer.parseInt(pasc[i-1][k-1]) + Integer.parseInt(pasc[i-1][k]));
- }
- for(int i = 0 ; i < 10; i++) {
- for(int k = 0; k < 10; k++) {
- if(k == 0) {
- this.giveSpace(4 * (10 - i));
- System.out.print(pasc2[i][k]);
- } else {
- this.giveSpace(8 - pasc2[i][k-1].length());
- System.out.print(pasc2[i][k]);
- }
- }
- System.out.print("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement