Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package NestedLoops;
- import java.util.Scanner;
- public class WeddingSeats {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- char lastSector = sc.nextLine().charAt(0);
- int rowsFirst = Integer.parseInt(sc.nextLine()) - 1;
- int places = Integer.parseInt(sc.nextLine());
- int count = 0;
- for (int a = 65; a <= lastSector; a++) {
- rowsFirst++;
- for (int b = 1; b <= rowsFirst; b++) {
- if (b % 2 == 0) {
- int newPlaces = places + 97 + 2;
- for (int c = 97; c < newPlaces; c++) {
- System.out.printf("%c%d%c%n", a, b, c);
- count++;
- }
- } else {
- int newPlaces = places + 97;
- for (int c = 97; c < newPlaces; c++) {
- System.out.printf("%c%d%c%n", a, b, c);
- count++;
- }
- }
- }
- }
- System.out.println(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement