Advertisement
Raul_julian

calc.java

Mar 19th, 2015
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1.  String[][] pasc = new String[10][10] ;
  2.        
  3.        for(int i = 0 ; i < 10; i++) {
  4.                 for(int k = 0; k < 10; k++)  
  5.                         pasc[i][k] = " " ;
  6.         }
  7.  
  8.         for(int i = 0 ; i < 10; i++) {
  9.                 for(int k = 0; k <= i; k++)  
  10.                         pasc[i][k] = "1" ;
  11.         }
  12.  
  13.         String[][] pasc2 = new String[10][10];
  14.         pasc2 = pasc ;
  15.  
  16.         for(int i = 2; i < 10; i++) {
  17.                 for(int k = 1; k < i; k++)
  18.                     pasc2[i][k] = String.valueOf(Integer.parseInt(pasc[i-1][k-1]) + Integer.parseInt(pasc[i-1][k]));  
  19.         }
  20.  
  21.         for(int i = 0 ; i < 10; i++) {
  22.                 for(int k = 0; k < 10; k++) {
  23.                     if(k == 0) {
  24.                         this.giveSpace(4 * (10 - i));
  25.                         System.out.print(pasc2[i][k]);
  26.                     } else {
  27.                         this.giveSpace(8 - pasc2[i][k-1].length());
  28.                          System.out.print(pasc2[i][k]);
  29.                     }
  30.                 }
  31.  
  32.                 System.out.print("\n");
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement