Advertisement
myrdok123

06. Building

Apr 13th, 2024
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. package NestedLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06Building {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.              int floors = Integer.parseInt(scanner.nextLine());
  10.              int rooms = Integer.parseInt(scanner.nextLine());
  11.  
  12.         for (int i = floors; i >= 1 ; i--) {
  13.  
  14.             for (int j = 0; j < rooms; j++) {
  15.  
  16.                 if (i == floors){
  17.                     System.out.printf("L%d%d ", i, j);
  18.                 } else if (i % 2 == 0) {
  19.                     System.out.printf("O%d%d ", i, j);
  20.                 }else {
  21.                     System.out.printf("A%d%d ", i, j);
  22.                 }
  23.  
  24.             }
  25.  
  26.             System.out.println();
  27.  
  28.         }
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement