Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Diamond {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n;
- do {
- n=sc.nextInt();
- } while(n<4 || n>32);
- for(int i=0;i<n;i++) {
- System.out.print(".");
- }
- for(int i=0;i<n*3;i++) {
- System.out.print("*");
- }
- for(int i=0;i<n;i++) {
- System.out.print(".");
- }
- System.out.println();
- //Горна Част
- for(int i=1;i<n;i++) {
- for(int j=0;j<n-i;j++) {
- System.out.print(".");
- }
- System.out.print("*");
- for(int j=0;j<(n*3)+(i-1)*2;j++) {
- System.out.print(".");
- }
- System.out.print("*");
- for(int j=0;j<n-i;j++) {
- System.out.print(".");
- }
- System.out.println();
- }
- for(int i=0;i<n*5;i++) {
- System.out.print("*");
- }
- System.out.println();
- //Долна Част
- for(int i=0;i<2*n;i++) {
- for(int j=0;j<i+1;j++) {
- System.out.print(".");
- }
- System.out.print("*");
- for(int j=0;j<5*n-(2*i)-4;j++) {
- System.out.print(".");
- }
- System.out.print("*");
- for(int j=0;j<i+1;j++) {
- System.out.print(".");
- }
- System.out.println();
- }
- for(int i=0;i<2*n+1;i++) {
- System.out.print(".");
- }
- for(int i=0;i<n-2;i++) {
- System.out.print("*");
- }
- for(int i=0;i<2*n+1;i++) {
- System.out.print(".");
- }
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement