Advertisement
desislava_topuzakova

5.Java

Mar 7th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class zadacha5 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int n = Integer.parseInt(scanner.nextLine());
  7. int shir = 3 * n + 6;
  8. int vis = 3 * n + 1;
  9. int counter1 = 0;
  10. int counter2 = 0;
  11.  
  12. for (int i = 0; i < n; i++) {
  13. System.out.print(repeatStr(" ", n));
  14. System.out.println("~ ~ ~");
  15.  
  16. }
  17. System.out.println(repeatStr("=", 3 * n + 5));
  18. for (int j = 1; j <= n - 2; j++) {
  19. String line = "|" + repeatStr("~", 2 * n + 4) + "|" + repeatStr(" ", n - 1) + "|";
  20.  
  21. if (j == n / 2) {
  22. line = "|" + repeatStr("~", n) + "JAVA" + repeatStr("~", n) + "|" + repeatStr(" ", n - 1) + "|";
  23. }
  24. System.out.println(line);
  25. }
  26. System.out.println(repeatStr("=", 3 * n + 5));
  27.  
  28. for (int m = 0; m < n; m++) {
  29.  
  30. System.out.print(repeatStr(" ", counter1));
  31. System.out.print("\\");
  32. System.out.print(repeatStr("@", 2 * n + 4 + counter2));
  33. System.out.println("/");
  34. counter1++;
  35. counter2 -= 2;
  36. }
  37. System.out.println(repeatStr("=", 2 * n + 6));
  38. }
  39.  
  40. static String repeatStr(String str, int count) {
  41. String text = "";
  42. {
  43. for (int j = 0; j < count; j++) {
  44. text = text + str;
  45. }
  46. }
  47. return text;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement