Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Building {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int floors = Integer.parseInt(scan.nextLine()); // прочитаме броя на етажите
- int rooms = Integer.parseInt(scan.nextLine()); // прочитаме броя на стаите за всеки етаж
- for (int floor = floors; floor >= 1; floor--) { // намаляващ for за всеки етаж, тъй като печатаме първо последният, а накрая 1ви
- for (int room = 0; room < rooms; room++) { // for за всяка стая на всеки етаж
- if (floor == floors) { // ако етажа е последен
- System.out.print("L" + floor + room + " "); // печатаме L за голям апартамент
- } else if (floor % 2 == 0) { // ако етажа е четен
- System.out.print("O" + floor + room + " "); // печатаме O за офис
- } else {
- System.out.print("A" + floor + room + " "); // печатаме A за апартамент
- }
- }
- System.out.println(); // преместваме курсора на следващият ред, за да следващият етаж
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement