Guest User

Untitled

a guest
Dec 11th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Kyle Scopa
  3. Write a program that requests an integer n and prints the following X picture.
  4.  
  5. Sample run:
  6. Enter a positive integer: 5
  7. Output:
  8.  
  9.  X       X
  10.   X     X
  11.    X   X
  12.     X X
  13.      X
  14.     X X
  15.    X   X
  16.   X     X
  17.  X       X
  18.  
  19. */
  20.     import java.util.*;
  21.    
  22.    
  23. public class PrintX
  24. {
  25.     public static void main(String args[])
  26.     {
  27.         int inp = 0;
  28.         int inc = 0;
  29.         int c = 0;
  30.        
  31.        
  32.         Scanner input = new Scanner(System.in);
  33.         inp = input.nextInt();
  34.        
  35.         //upper left..
  36.         for (int i=1; i<inp; i++){
  37.             for(int check= 1; check<i; check++){
  38.                 System.out.print(" ");
  39.             }
  40.             System.out.println("X");
  41.             for (int l = (inp*2)-3-2*inc;l > 0;l--){
  42.                 System.out.print(" ");
  43.         }
  44.                 System.out.printlx("x");
  45.                 inc++;
  46.             }
  47.    
  48.    
  49.    
  50.     //middle x
  51.     for (int p = 1; p <inp; p++){
  52.         System.out.print(" ");
  53.     }
  54.     System.out.println("x");
  55.     //lower left x
  56.      for (int q = inp; q>1; q--){
  57.         for(int check1 = 2; check1<q; check1++){
  58.             System.out.print(" ");
  59.            
  60.         }
  61.        
  62.         System.out.println("x");
  63.      
  64.      
  65.      
  66.  
  67.         }
  68.    
  69.     }
  70. }
Add Comment
Please, Sign In to add comment