Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TheExplorer {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = scan.nextInt();
- int dashesIncreasing = n / 2;
- int dashesDecreasing = n / 2;
- //top line
- System.out.print(new String(new char[n/2]).replace('\0', '-'));
- System.out.print('*');
- System.out.println(new String(new char[n/2]).replace('\0', '-'));
- //upper middle
- for (int i = 0; i < n/2 - 1; i++) {
- System.out.print(new String(new char[dashesDecreasing - 1]).replace('\0', '-'));
- System.out.print('*');
- System.out.print(
- new String(new char[dashesIncreasing - (n/2 - 1)]).replace('\0', '-'));
- System.out.print('*');
- System.out.println(new String(new char[dashesDecreasing - 1]).replace('\0', '-'));
- dashesIncreasing+=2;
- dashesDecreasing--;
- }
- //middle
- System.out.print('*');
- System.out.print(new String(new char[n - 2]).replace('\0', '-'));
- System.out.println('*');
- dashesDecreasing = n - 2;
- dashesIncreasing = 1;
- //lower middle
- for (int i = 0; i < n/2 - 1; i++) {
- System.out.print(new String(new char[dashesIncreasing]).replace('\0', '-'));
- System.out.print('*');
- System.out.print(new String(new char[dashesDecreasing - 2]).replace('\0', '-'));
- System.out.print('*');
- System.out.println(new String(new char[dashesIncreasing]).replace('\0', '-'));
- dashesDecreasing-=2;
- dashesIncreasing++;
- }
- //bottom line
- System.out.print(new String(new char[n/2]).replace('\0', '-'));
- System.out.print('*');
- System.out.println(new String(new char[n/2]).replace('\0', '-'));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement