Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Drawing_With_Loops - created by borkins on 2017-04-02.
- */
- import java.util.Scanner;
- public class _09_House
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- StringBuilder roof = new StringBuilder();
- int n = Integer.parseInt(console.nextLine());
- roof.append((n % 2 == 0) ? "**" : "*");
- for (int row = 0; row < n - n / 2; row++)
- {
- for (int col = 0; col <= n - roof.length(); col++)
- {
- if (col != (n - roof.length()) / 2) {
- System.out.print("-");
- }
- else {
- System.out.print(roof);
- }
- }
- System.out.println();
- roof.append("**");
- }
- for (int row = 0; row < n / 2; row++)
- {
- System.out.print("|");
- for (int col = 0; col < n - 2; col++) {
- System.out.print("*");
- }
- System.out.println("|");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment