Advertisement
desislava_topuzakova

Sheriff

Nov 4th, 2017
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.94 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Sheriff {
  3. public static void main(String[] args) {
  4. Scanner scanner=new Scanner(System.in);
  5. int n=Integer.parseInt(scanner.nextLine());
  6. int m=n;
  7. int p=n;
  8. int q=n;
  9. int a1=0;
  10. int a2=0;
  11. int count_tochki=((3*n)-1)/2;
  12. int lenght_red=3*n;
  13. int half_red=(lenght_red-1)/2;
  14. int half_koloni=(((2*n)+8)-8)/2;
  15.  
  16. { System.out.print(repeatStr(".",count_tochki));
  17. System.out.print("x");
  18. System.out.println(repeatStr(".",count_tochki));//red 1
  19.  
  20. System.out.print(repeatStr(".",count_tochki-1));
  21. System.out.print("/x\\");
  22. System.out.println(repeatStr(".",count_tochki-1));//red 2
  23.  
  24. System.out.print(repeatStr(".",count_tochki-1));
  25. System.out.print("x|x");
  26. System.out.println(repeatStr(".",count_tochki-1));//red3
  27.  
  28. for ( int a = 0; a <(half_koloni-1)/2 ; a++) {
  29.  
  30. System.out.print(repeatStr(".",Math.abs(half_red-n)));
  31. System.out.print(repeatStr("x",n));
  32. System.out.print("|");
  33. System.out.print(repeatStr("x",n));
  34. System.out.println(repeatStr(".",(Math.abs(half_red-n))));
  35. n++;
  36. a1=a1+a;}
  37.  
  38. System.out.print(repeatStr("x",n));
  39. System.out.print("|");
  40. System.out.println(repeatStr("x",n));
  41. if(m<=n){ m=n-1;
  42. for (int b = 0; b <(half_koloni-1)/2 ; b++) {
  43.  
  44. System.out.print(repeatStr(".",Math.abs(half_red-m)));
  45. System.out.print(repeatStr("x",m));
  46. System.out.print("|");
  47. System.out.print(repeatStr("x",m));
  48. System.out.println(repeatStr(".",Math.abs(half_red-m)));
  49. m--;}}
  50. else {m=n+a1;
  51. for (int i = 0; i <(half_koloni-1)/2 ; i++) {
  52. System.out.print(repeatStr(".",Math.abs(half_red-m)));
  53. System.out.print(repeatStr("x",m));
  54. System.out.print("|");
  55. System.out.print(repeatStr("x",m));
  56. System.out.println(repeatStr(".",Math.abs(half_red-m)));
  57. m--;}}
  58.  
  59. System.out.print(repeatStr(".",count_tochki-1));
  60. System.out.print("/x\\");
  61. System.out.println(repeatStr(".",count_tochki-1));
  62.  
  63. System.out.print(repeatStr(".",count_tochki-1));
  64. System.out.print("\\x/");
  65. System.out.println(repeatStr(".",count_tochki-1));
  66. //dolna chast
  67. {
  68. for (int j = 0; j <(half_koloni-1)/2 ; j++) {
  69.  
  70. System.out.print(repeatStr(".",Math.abs(half_red-p)));
  71. System.out.print(repeatStr("x",p));
  72. System.out.print("|");
  73. System.out.print(repeatStr("x",p));
  74. System.out.println(repeatStr(".",Math.abs(half_red-p)));
  75. p++;
  76. a2=a2+j;}
  77.  
  78. System.out.print(repeatStr("x",p));
  79. System.out.print("|");
  80. System.out.println(repeatStr("x",p));
  81. if(q<=p){q=p-1;
  82. for ( int d = 0; d <(half_koloni-1)/2 ; d++)
  83.  
  84. {System.out.print(repeatStr(".",Math.abs(half_red-q)));
  85. System.out.print(repeatStr("x",q));
  86. System.out.print("|");
  87. System.out.print(repeatStr("x",q));
  88. System.out.println(repeatStr(".",Math.abs(half_red-q)));
  89. q--;}}
  90. else
  91. {q=p+a2;
  92.  
  93. q++;
  94. for (int f = 0; f <(half_koloni-1)/2 ; f++) {
  95.  
  96. System.out.print(repeatStr(".",Math.abs(half_red-q)));
  97. System.out.print(repeatStr("x",q));
  98. System.out.print("|");
  99. System.out.print(repeatStr("x",q));
  100. System.out.println(repeatStr(".",Math.abs(half_red-q)));
  101. q--;}}
  102.  
  103. System.out.print(repeatStr(".",count_tochki-1));
  104. System.out.print("x|x ");
  105. System.out.println(repeatStr(".",count_tochki-1));
  106.  
  107. System.out.print(repeatStr(".",count_tochki-1));
  108. System.out.print("\\x/");
  109. System.out.println(repeatStr(".",count_tochki-1));
  110.  
  111. System.out.print(repeatStr(".",count_tochki));
  112. System.out.print("x");
  113. System.out.println(repeatStr(".",count_tochki));}}}
  114.  
  115. static String repeatStr(String str, int count ){
  116. String text="";
  117. {
  118. for (int j = 0; j <count ; j++) {
  119. text=text+str;
  120. }
  121.  
  122. }
  123. return text;
  124. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement