Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Exam_17_July_2016 - created by borkins on 2017-05-16.
- */
- import java.util.Scanner;
- public class _05_Diamond
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int n = Integer.parseInt(console.nextLine());
- for (int i = 0, j = n * 3; i < n; i++, j += 2)
- {
- printStr(".", (n - i));
- printStr("*", 1);
- printStr((i > 0) ? "." : "*", j - 2);
- printStr("*", 1);
- printStr(".", (n - i));
- System.out.println();
- }
- printStr("*", (n * 5));
- System.out.println();
- for (int i = 0, j = n * 5 - 4; i <= n * 2; i++, j -= 2)
- {
- printStr(".", (i + 1));
- printStr("*", 1);
- printStr((i < n * 2) ? "." : "*", j);
- printStr("*", 1);
- printStr(".", (i + 1));
- System.out.println();
- }
- }
- public static void printStr(String str, int count)
- {
- for (int i = 0; i < count; i++) {
- System.out.print(str);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment