Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Building
- {
- class Program
- {
- static void Main(string[] args)
- {
- int floors = int.Parse(Console.ReadLine());
- int volume = int.Parse(Console.ReadLine());
- for (int floor = floors; floor > 0; floor--)
- {
- char index = ' ';
- string currentFloor = "";
- for (int flat = 0; flat < volume; flat++)
- {
- if (floors == floor)
- {
- index = 'L';
- }
- else
- {
- if (floor % 2 == 0)
- {
- index = 'O';
- }
- else
- {
- index = 'A';
- }
- }
- currentFloor += $"{ index}{ floor}{ flat} ";
- }
- Console.WriteLine(currentFloor);
- }
- }
- }
- }
- Решение с тернарен оператор:
- using System;
- namespace Building
- {
- class Program
- {
- static void Main(string[] args)
- {
- int floors = int.Parse(Console.ReadLine());
- int volume = int.Parse(Console.ReadLine());
- for (int floor = floors; floor > 0; floor--)
- {
- for (int flat = 0; flat < volume; flat++)
- {
- Console.Write($"{ (floors == floor ? 'L' : floor % 2 == 0 ? 'O' : 'A')}{ floor}{ flat} ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement