Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class WeddingSeats {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- char lastSector = scanner.nextLine().charAt(0);
- int rowCount = Integer.parseInt(scanner.nextLine());
- int seatCount = Integer.parseInt(scanner.nextLine());
- int counter = 0;
- for (char sector = 'A'; sector <= lastSector; sector++, rowCount++) {
- for (int row = 1; row <= rowCount; row++) {
- int seatInRow = seatCount;
- if (row % 2 == 0) {
- seatInRow = seatCount + 2;
- }
- for (char seat = 'a'; seat < 'a' + seatInRow; seat++) {
- System.out.printf("%c%d%c%n", sector, row, seat);
- counter++;
- }
- }
- }
- System.out.print(counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement