Guest User

Untitled

a guest
Dec 12th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Pattern4 {
  4. public static void main (String[] args) {
  5. System.out.println("/* ===== Pattern #4 ===== */");
  6. Scanner input = new Scanner(System.in);
  7. int n = input.nextInt(), i, j;
  8.  
  9. for (i=1; i<=n; i++) {
  10. // Print left white spaces
  11. for (j=n; j>i; j--) {
  12. System.out.print(" ");
  13. }
  14.  
  15. // Print the numbers
  16. for (j=i; j<=(2*i-1); j++) {
  17. System.out.print(j + " ");
  18. }
  19.  
  20. for (j=(2*i-1) - 1; j>=i; j--) {
  21. System.out.print(j + " ");
  22. }
  23.  
  24. System.out.println("");
  25. }
  26.  
  27. }
  28. }
Add Comment
Please, Sign In to add comment