Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enter odd numer and get this (example 7)
- ---*---
- --*-*--
- -*---*-
- *-----*
- -*---*-
- --*-*--
- ---*---
- package FinalCSharpTest;
- import java.util.Scanner;
- public class TheExplorer {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = scan.nextInt();
- char core = '*';
- char outin = '-';
- int statOne = 1;
- int statTwo = n/2-1;
- // top
- topbottom(n/2, outin);
- topbottom(1, core);
- topbottom(n/2, outin);
- System.out.println();
- for (int i = 0; i < n/2-1; i++) {
- coreString(statTwo, outin);
- coreString(1, core);
- coreString(statOne, outin);
- coreString(1, core);
- coreString(statTwo, outin);
- statOne+=2;
- statTwo--;
- System.out.println();
- }
- //mid
- topbottom(1, core);
- topbottom(n-2, outin);
- topbottom(1, core);
- System.out.println();
- for (int i = 0; i < n/2-1; i++) {
- statOne-=2;
- statTwo++;
- coreString(statTwo, outin);
- coreString(1, core);
- coreString(statOne, outin);
- coreString(1, core);
- coreString(statTwo, outin);
- System.out.println();
- }
- //bottom
- topbottom(n/2, outin);
- topbottom(1, core);
- topbottom(n/2, outin);
- }
- static void coreString(int n , char ch) {
- for (int i = 0; i <n; i++) {
- System.out.print(ch);
- }
- }
- static void topbottom(int n , char ch) {
- for (int i = 0; i <n; i++) {
- System.out.print(ch);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement