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 countRowsInFirstSector = Integer.parseInt(scanner.nextLine());
- int countSeatsOddRow = Integer.parseInt(scanner.nextLine());
- int stopSecondSector = countRowsInFirstSector;
- int counterSeatsTotal = 0;
- StringBuilder sb = new StringBuilder();
- for (char i = 'A'; i <= lastSector ; i++) {
- for (int j = 1; j <= stopSecondSector; j++) {
- if (j % 2 != 0){
- for (char k = 'a'; k < 'a'+ countSeatsOddRow ; k++) {
- sb.append(i);
- sb.append(j);
- sb.append(k);
- sb.append(System.lineSeparator());
- counterSeatsTotal++;
- }
- } else if (j % 2 == 0){
- for (char k = 'a'; k < 'a' + (2 + countSeatsOddRow) ; k++) {
- sb.append(i);
- sb.append(j);
- sb.append(k);
- sb.append(System.lineSeparator());
- counterSeatsTotal++;
- }
- }
- }
- stopSecondSector++;
- }
- System.out.println(sb.toString());
- System.out.printf("%d", counterSeatsTotal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement