Advertisement
tolem

printFormation

Mar 4th, 2022
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public static void main(String[] args) {
  2.  
  3. printFormation2(8);
  4.  
  5. }
  6.  
  7. private static void printFormation2(int number) {
  8.  
  9. number = number * 2 + 1;
  10. for (int row = 1; row < number; row++) {
  11. for (int column = 1; column <= number; column++) {
  12.  
  13. if ((row == column || column == number - row + 1) && row < number / 2 + 1) {
  14. System.out.print(column <= number / 2 ? "\\" : "/");
  15. } else if (column == number / 2 + 1) {
  16. System.out.print("|");
  17. } else {
  18. System.out.print(".");
  19. }
  20. }
  21. System.out.println();
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement