Advertisement
desislava_topuzakova

06. Building

May 30th, 2020
970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class demo {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int floors = Integer.parseInt(scanner.nextLine());
  8.         int rooms = Integer.parseInt(scanner.nextLine());
  9.  
  10.         for (int floor = floors; floor >= 1; floor--) {
  11.             //за всеки един етаж -> минем през стаите му
  12.             for (int room = 0; room < rooms; room++) {
  13.                 //проверка за етажа
  14.                 //1. последен
  15.                 //2. четен ->
  16.                 //3. нечетен
  17.                 if (floor == floors) {
  18.                     System.out.printf("L%d%d ", floor, room);
  19.                 } else if (floor % 2 == 0) {
  20.                     System.out.printf("O%d%d ", floor, room);
  21.                 } else if (floor % 2 == 1) {
  22.                     System.out.printf("A%d%d ", floor, room);
  23.                 }
  24.             }
  25.             System.out.println();
  26.         }
  27.  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement