Advertisement
desislava_topuzakova

06. Building

May 15th, 2021
815
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1.  
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class demo2 {
  6.     public static void main(String[] args){
  7.         Scanner scanner = new Scanner(System.in);
  8.         //1. етажите от последния към първия
  9.         //2. за всеки един етаж -> стаите от 0 до последната
  10.         int floors = Integer.parseInt(scanner.nextLine());
  11.         int rooms = Integer.parseInt(scanner.nextLine());
  12.         for (int floor = floors; floor >= 1 ; floor--) {
  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 == 1) {
  18.                     System.out.printf("A%d%d ",floor, room);
  19.                 } else if (floor % 2 == 0) {
  20.                     System.out.printf("O%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