fork download
  1. class M{
  2. static String c(int n){
  3. String a = "+x |",
  4. b = "|y|\n",
  5. x = "",
  6. y = "",
  7. r = "";
  8. int i = 0;
  9. for (; i++ < n-2;){
  10. x += i > 1
  11. ? "-"
  12. : "";
  13. y += " ";
  14. }
  15. a = a.replace("x", x);
  16. b = b.replace("y", y);
  17. for(i = 0; i < n; i++){
  18. r += i % 4 < 1
  19. ? a+"\n"
  20. : (i-2) % 4 == 0
  21. ? new StringBuffer(a).reverse()+"\n"
  22. : b;
  23. }
  24. return r;
  25. }
  26.  
  27. public static void main(String[] a){
  28. System.out.println(c(7));
  29. System.out.println();
  30. System.out.println(c(25));
  31. }
  32. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
+---- |
|     |
| ----+
|     |
+---- |
|     |
| ----+


+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |