Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Z4_Piramid {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Enter number of lines: ");
- int num = input.nextInt();
- piramid(num);
- input.close();
- }
- public static void piramid(int n){
- for(int i = 1; i <= n; i++){
- for(int j = n; j > 0; j--){
- if(j <= i){
- System.out.print(j + " ");
- } else {
- System.out.print(" ");
- }
- }
- for(int k = 2; k <= n; k++){
- if(k <= i){
- System.out.print(k + " ");
- } else {
- System.out.print(" ");
- }
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement