Advertisement
desislava_topuzakova

06. Building

Jul 9th, 2022
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P06.Building
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int floors = int.Parse(Console.ReadLine());
  10.             int apartments = int.Parse(Console.ReadLine());
  11.            
  12.             //Goes through all floors from top to bottom
  13.             for (int fl = floors; fl >= 1; fl--)
  14.             {
  15.                 //Goes through all apartments/offices on a single floor
  16.                 for (int ap = 0; ap < apartments; ap++)
  17.                 {
  18.                     //Combination -> Floor, Apartment
  19.                     //Last Floor
  20.                     if (fl == floors)
  21.                     {
  22.                         Console.Write($"L{fl}{ap} ");
  23.                     }
  24.                     else if (fl % 2 != 0)
  25.                     {
  26.                         Console.Write($"A{fl}{ap} ");
  27.                     }
  28.                     else if (fl % 2 == 0)
  29.                     {
  30.                         Console.Write($"O{fl}{ap} ");
  31.                     }
  32.                 }
  33.  
  34.                 //Visually move to the next floor
  35.                 Console.WriteLine();
  36.             }
  37.         }
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement