Advertisement
veronikaaa86

6. Сграда

Feb 11th, 2023
1,160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. package nestedLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06Building {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int floors = Integer.parseInt(scanner.nextLine());
  10.         int rooms = Integer.parseInt(scanner.nextLine());
  11.  
  12.         for (int f = floors; f >= 1; f--) {
  13.             for (int r = 0; r < rooms; r++) {
  14.                 if (f == floors) {
  15.                     System.out.printf("L%d%d ", f, r);
  16.                 } else if (f % 2 == 0) {
  17.                     System.out.printf("O%d%d ", f, r);
  18.                 } else {
  19.                     System.out.printf("A%d%d ", f, r);
  20.                 }
  21.  
  22.             }
  23.             System.out.println();
  24.         }
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement