Advertisement
Dido09

Diamond

Jan 2nd, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Diamond {
  4.  
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner(System.in);
  7.  
  8. int n;
  9. do {
  10. n=sc.nextInt();
  11. } while(n<4 || n>32);
  12.  
  13.  
  14. for(int i=0;i<n;i++) {
  15. System.out.print(".");
  16. }
  17. for(int i=0;i<n*3;i++) {
  18. System.out.print("*");
  19. }
  20. for(int i=0;i<n;i++) {
  21. System.out.print(".");
  22. }
  23. System.out.println();
  24.  
  25. //Горна Част
  26. for(int i=1;i<n;i++) {
  27. for(int j=0;j<n-i;j++) {
  28. System.out.print(".");
  29. }
  30. System.out.print("*");
  31. for(int j=0;j<(n*3)+(i-1)*2;j++) {
  32. System.out.print(".");
  33. }
  34. System.out.print("*");
  35. for(int j=0;j<n-i;j++) {
  36. System.out.print(".");
  37. }
  38. System.out.println();
  39. }
  40.  
  41. for(int i=0;i<n*5;i++) {
  42. System.out.print("*");
  43. }
  44. System.out.println();
  45.  
  46. //Долна Част
  47. for(int i=0;i<2*n;i++) {
  48. for(int j=0;j<i+1;j++) {
  49. System.out.print(".");
  50. }
  51. System.out.print("*");
  52. for(int j=0;j<5*n-(2*i)-4;j++) {
  53. System.out.print(".");
  54. }
  55. System.out.print("*");
  56. for(int j=0;j<i+1;j++) {
  57. System.out.print(".");
  58. }
  59. System.out.println();
  60. }
  61.  
  62. for(int i=0;i<2*n+1;i++) {
  63. System.out.print(".");
  64. }
  65. for(int i=0;i<n-2;i++) {
  66. System.out.print("*");
  67. }
  68. for(int i=0;i<2*n+1;i++) {
  69. System.out.print(".");
  70. }
  71.  
  72. sc.close();
  73. }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement