Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ProgrammingBasics.NestedLoops;
- 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 firstRow = Integer.parseInt(scanner.nextLine()) - 1;
- int places = Integer.parseInt(scanner.nextLine());
- int count = 0;
- for (int i = 65; i <= lastSector; i++) {
- firstRow++;
- for (int j = 1; j <= firstRow; j++) {
- if (j % 2 == 0) {
- int newPlaces = places + 97 + 2;
- for (int k = 97; k < newPlaces; k++) {
- System.out.printf("%c%d%c%n", i, j, k);
- count++;
- }
- } else {
- int newPlaces = places + 97;
- for (int c = 97; c < newPlaces; c++) {
- System.out.printf("%c%d%c%n", i, j, c);
- count++;
- }
- }
- }
- }
- System.out.println(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement