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