Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Pattern4 {
- public static void main (String[] args) {
- System.out.println("/* ===== Pattern #4 ===== */");
- Scanner input = new Scanner(System.in);
- int n = input.nextInt(), i, j;
- for (i=1; i<=n; i++) {
- // Print left white spaces
- for (j=n; j>i; j--) {
- System.out.print(" ");
- }
- // Print the numbers
- for (j=i; j<=(2*i-1); j++) {
- System.out.print(j + " ");
- }
- for (j=(2*i-1) - 1; j>=i; j--) {
- System.out.print(j + " ");
- }
- System.out.println("");
- }
- }
- }
Add Comment
Please, Sign In to add comment