Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class House {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 1; i <= (n + 1) / 2; i++) {
- for (int j = 0; j < (n + 1) / 2 - i; j++) {
- System.out.print("-");
- }
- if (n % 2 == 1) {
- System.out.print("*");
- } else {
- System.out.print("**");
- }
- for (int k = 1; k < i; k++) {
- System.out.print("**");
- }
- for (int j = 0; j < (n + 1) / 2 - i; j++) {
- System.out.print("-");
- }
- System.out.println();
- }
- for (int i = 0; i < n / 2; i++) {
- System.out.print("|");
- for (int x = 0; x < n - 2; x++) {
- System.out.print("*");
- }
- System.out.println("|");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement