Guest User

Untitled

a guest
Jan 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Pascal {
  4. public static void main(String[] args) {
  5.  
  6. Scanner inputk = new Scanner(System.in);
  7. int n = 0;
  8.  
  9. do {
  10. System.out.println("Entrez un entier >= 1 ");
  11. n = inputk.nextInt();
  12. } while (n < 1);
  13.  
  14. int[][] tableau;
  15.  
  16. for (int i = 0; i < n; i++) {
  17. if (i == 0) {
  18. tableau = new int[n][i+1];
  19. } else {
  20. tableau = int[i+1][i+1];
  21. }
  22. for (int j = 0; j < (i+1); j++) {
  23. if (j == 0 || j == i || i == 0) {
  24. tableau[i][j] = 1;
  25. } else {
  26. tableau[i][j] = tableau[i-1][j-1] + tableau[i-1][j];
  27. System.out.print(tableau[i-1][j-1] + " " + tableau[i-1][j]);
  28. }
  29.  
  30. }
  31.  
  32. //affichage
  33.  
  34. for (int k = 0; k < (i+1); k++) {
  35. // System.out.print(tableau[i][k] + " ");
  36. }
  37. System.out.println();
  38. }
  39. }
  40.  
  41. }
Add Comment
Please, Sign In to add comment