Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class p05_Sword {
  4. public static void main(String[] args) {
  5. Scanner console = new Scanner(System.in);
  6. int n = Integer.parseInt(console.nextLine());
  7. int width = 2 * n + 1;
  8.  
  9. //top
  10. System.out.printf("%s/^\\%s%n", repeatStr("#", n - 1), repeatStr("#", n - 1));
  11. for (int row = 0; row < n / 2; row++) {
  12. System.out.printf("%s.%s.%s%n", repeatStr("#", n - 2 - row),
  13. repeatStr(" ", 3 + 2 * row),
  14. repeatStr("#", n - 2 - row));
  15. }
  16.  
  17. //blade
  18. for (int row = 0; row < n+3; row++) {
  19. System.out.printf("%s|%s", repeatStr("#", (n - 1) / 2),
  20. repeatStr(" ", n / 2));
  21. if (row == 0){
  22. System.out.print("S");
  23. }else if (row == 1){
  24. System.out.print("O");
  25. }else if (row == 2){
  26. System.out.print("F");
  27. }else if (row == 3){
  28. System.out.print("T");
  29. }else if (row == n){
  30. System.out.print("U");
  31. }else if (row == n+1){
  32. System.out.print("N");
  33. }else if (row == n+2){
  34. System.out.print("I");
  35. }else {
  36. System.out.print(" ");
  37. }
  38. System.out.printf("%s|%s%n", repeatStr(" ", n / 2),
  39. repeatStr("#", (n - 1) / 2));
  40. }
  41.  
  42. //handle
  43. System.out.printf("@%s@%n", repeatStr("=", width-2));
  44. for (int row = 0; row < n / 2; row++) {
  45. System.out.printf("%s|%s|%s%n", repeatStr("#", (n+3)/2),
  46. repeatStr(" ", width-2*((n+3)/2)-2),
  47. repeatStr("#", (n+3)/2));
  48. }
  49. System.out.printf("%s\\%s/%s", repeatStr("#", (n+3)/2),
  50. repeatStr(".", width-2*((n+3)/2)-2) ,
  51. repeatStr("#", (n+3)/2 ));
  52. }
  53.  
  54. static String repeatStr(String text, int count) {
  55. StringBuilder sb = new StringBuilder();
  56. for (int i = 0; i < count; i++) {
  57. sb.append(text);
  58. }
  59. return sb.toString();
  60. }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement