Advertisement
Dianov

Nested Loops - Lab (06. Building)

Dec 31st, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Building
  8.  
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int floors = int.Parse(Console.ReadLine());
  15.             int rooms = int.Parse(Console.ReadLine());
  16.  
  17.             for (int i = floors; i > 0 ; i--)
  18.             {
  19.                 for (int j = 0; j < rooms; j++)
  20.                 {
  21.                     if (i == floors)
  22.                     {
  23.                         if (j != (rooms - 1))
  24.                         {
  25.                             Console.Write($"L{i}{j} ");
  26.                         }
  27.                         else
  28.                         {
  29.                             Console.WriteLine($"L{i}{j}");
  30.                         }
  31.                     }
  32.                     else if (i % 2 == 0)
  33.                     {
  34.                         if (j != (rooms - 1))
  35.                         {
  36.                             Console.Write($"O{i}{j} ");
  37.                         }
  38.                         else
  39.                         {
  40.                             Console.WriteLine($"O{i}{j}");
  41.                         }                                              
  42.                     }
  43.                     else
  44.                     {
  45.                         if (j != (rooms - 1))
  46.                         {
  47.                             Console.Write($"A{i}{j} ");
  48.                         }
  49.                         else
  50.                         {
  51.                             Console.WriteLine($"A{i}{j}");
  52.                         }
  53.                     }
  54.                 }
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement