Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PascalTriangle02 {
- public static void main(String[] args) {
- Scanner scanner=new Scanner(System.in);
- int n=Integer.parseInt(scanner.nextLine());
- int[]numbers=new int[n];
- int[]count=new int[n];
- int sum=0;
- for (int rowls = 0; rowls <n ; rowls++) {
- if (rowls==0||rowls==n-1){
- numbers[rowls]=1;
- count[rowls]=numbers[rowls];
- }else{
- for (int i = 0; i <rowls ; i++) {
- if (i==0){
- count[rowls]=numbers[i];
- }else {
- count[rowls]=numbers[rowls]+numbers[rowls-1];
- }
- }
- }
- for (int i = 0; i < count[rowls]; i++) {
- System.out.print(count[i]+ " ");
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement