Advertisement
Filkolev

WeddingSeats

Feb 24th, 2019
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2.  
  3. class WeddingSeats
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         char lastSector = char.Parse(Console.ReadLine());
  8.         int rowsInSector = int.Parse(Console.ReadLine());
  9.         int seatsInOddRows = int.Parse(Console.ReadLine());
  10.  
  11.         int seatsInEvenRows = seatsInOddRows + 2;
  12.  
  13.         int count = 0;
  14.         for (char sector = 'A'; sector <= lastSector; sector++)
  15.         {
  16.             for (int row = 1; row <= rowsInSector; row++)
  17.             {
  18.                 int seatsInCurrentRow;
  19.                 if (row % 2 != 0)
  20.                 {
  21.                     seatsInCurrentRow = seatsInOddRows;
  22.                 }
  23.                 else
  24.                 {
  25.                     seatsInCurrentRow = seatsInEvenRows;
  26.                 }
  27.  
  28.                 for (char seat = 'a'; seat <= 'a' + seatsInCurrentRow - 1; seat++)
  29.                 {
  30.                     Console.WriteLine($"{sector}{row}{seat}");
  31.                     count++;
  32.                 }
  33.             }
  34.  
  35.             rowsInSector++;
  36.         }
  37.  
  38.         Console.WriteLine(count);
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement