Advertisement
coasterka

TheExplorer

May 26th, 2014
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TheExplorer {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         Scanner scan = new Scanner(System.in);
  8.         int n = scan.nextInt();
  9.         int dashesIncreasing = n / 2;
  10.         int dashesDecreasing = n / 2;
  11.        
  12.         //top line
  13.         System.out.print(new String(new char[n/2]).replace('\0', '-'));
  14.         System.out.print('*');
  15.         System.out.println(new String(new char[n/2]).replace('\0', '-'));
  16.        
  17.         //upper middle
  18.         for (int i = 0; i < n/2 - 1; i++) {
  19.            
  20.             System.out.print(new String(new char[dashesDecreasing - 1]).replace('\0', '-'));               
  21.             System.out.print('*');
  22.             System.out.print(
  23.             new String(new char[dashesIncreasing  - (n/2 - 1)]).replace('\0', '-'));
  24.             System.out.print('*');
  25.             System.out.println(new String(new char[dashesDecreasing - 1]).replace('\0', '-'));
  26.            
  27.             dashesIncreasing+=2;
  28.             dashesDecreasing--;
  29.         }
  30.        
  31.         //middle
  32.         System.out.print('*');
  33.         System.out.print(new String(new char[n - 2]).replace('\0', '-'));
  34.         System.out.println('*');
  35.        
  36.         dashesDecreasing = n - 2;
  37.         dashesIncreasing = 1;
  38.        
  39.         //lower middle
  40.         for (int i = 0; i < n/2 - 1; i++) {        
  41.            
  42.             System.out.print(new String(new char[dashesIncreasing]).replace('\0', '-'));           
  43.             System.out.print('*');
  44.             System.out.print(new String(new char[dashesDecreasing - 2]).replace('\0', '-'));
  45.             System.out.print('*');
  46.             System.out.println(new String(new char[dashesIncreasing]).replace('\0', '-'));
  47.            
  48.             dashesDecreasing-=2;
  49.             dashesIncreasing++;
  50.         }
  51.        
  52.         //bottom line
  53.         System.out.print(new String(new char[n/2]).replace('\0', '-'));
  54.         System.out.print('*');
  55.         System.out.println(new String(new char[n/2]).replace('\0', '-'));
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement