Advertisement
deyanivanov966

06. Building

Apr 5th, 2021
140
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 t04 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int floors = Integer.parseInt(scanner.nextLine());
  7.         int rooms = Integer.parseInt(scanner.nextLine());
  8.  
  9.         //1. преминем през всички етажи от последния към първия
  10.         for (int floor = floors; floor >= 1; floor--) {
  11.             //за всеки един етаж
  12.             //минем през всички стаи
  13.             for (int room = 0; room < rooms; room++) {
  14.                 //последен
  15.                 if (floor == floors) {
  16.                     System.out.printf("L%d%d ", floor, room);
  17.                 } else if (floor % 2 == 0) {
  18.                     System.out.printf("O%d%d ", floor, room);
  19.                 } else if (floor % 2 == 1) {
  20.                     System.out.printf("A%d%d ", floor, room);
  21.                 }
  22.             }
  23.             System.out.println();
  24.         }
  25.  
  26.  
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement