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 scanner = new Scanner(System.in);
- int floorCount = Integer.parseInt(scanner.nextLine());
- int flatFloorCount = Integer.parseInt(scanner.nextLine());
- String appendix;
- for (int floor = floorCount; floor > 0; floor--) {
- if (floor == floorCount) {
- appendix = "L";
- } else if (floor % 2 == 1) {
- appendix = "A";
- } else {
- appendix = "O";
- }
- for (int flatFloor = 0; flatFloor < flatFloorCount; flatFloor++) {
- System.out.printf("%s%d%d ", appendix, floor, flatFloor);
- }
- System.out.println();
- }
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class Building {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int floorCount = Integer.parseInt(scanner.nextLine());
- int flatFloorCount = Integer.parseInt(scanner.nextLine());
- String appendix;
- for (int floor = floorCount; floor > 0; floor--) {
- appendix = floor == floorCount ? "L" : floor % 2 == 1 ? "A" : "O";
- for (int flatFloor = 0; flatFloor < flatFloorCount; flatFloor++) {
- System.out.printf("%s%d%d ", appendix, floor, flatFloor);
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement