Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package November2018;
- import java.util.Scanner;
- public class O6WeddingSeats {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- char sector = scanner.nextLine().charAt(0);
- int rows1Sector = Integer.parseInt(scanner.nextLine());
- int oddRowSeats = Integer.parseInt(scanner.nextLine());
- int count = 0;
- for (char i = 'A'; i <= sector; i++) {
- for (int j = 1; j <= rows1Sector ; j++) {
- if (j % 2 == 1) {
- for (char k = 'a'; k <= (96 + oddRowSeats); k++) {
- System.out.printf("%s%d%s%n", i, j, k);
- count++;
- }
- } else if (j%2==0) {
- for (char k = 'a'; k <= (96 + (oddRowSeats+2)); k++) {
- System.out.printf("%s%d%s%n", i, j, k);
- count++;
- }
- }
- }
- rows1Sector++;
- }
- System.out.println(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment