fork download
  1. using System;
  2.  
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. var s = new Stairway(3, 10);
  8. s.Print();
  9. Console.ReadLine();
  10. }
  11.  
  12. }
  13.  
  14. public class Stairway
  15. {
  16.  
  17. public Stairway(int depth, int count)
  18. {
  19. StepCount = count;
  20. NominalStepDepth = depth;
  21. }
  22.  
  23. public int NominalStepDepth { get; set; }
  24.  
  25. public int RealStepDepth { get { return NominalStepDepth + 1; } }
  26.  
  27. public int StepCount { get; set; }
  28.  
  29. public int TopStep { get { return StepCount; } }
  30.  
  31. private bool IsValid
  32. {
  33. get { return NominalStepDepth > 0 && StepCount > 0; }
  34. }
  35.  
  36. private string GetStepText(int step)
  37. {
  38. var padding = new string(' ', RealStepDepth * step);
  39. var floor = new string('_', NominalStepDepth);
  40. var wall = step == TopStep ? "" : "|";
  41.  
  42. return padding + floor + wall;
  43. }
  44.  
  45. public void Print()
  46. {
  47. if (IsValid)
  48. for (int i = TopStep; i >= 0 ; i--)
  49. Console.WriteLine(GetStepText(i));
  50. else
  51. Console.Write("NONE");
  52. }
  53. }
Success #stdin #stdout 0s 29672KB
stdin
Standard input is empty
stdout
                                        ___
                                    ___|
                                ___|
                            ___|
                        ___|
                    ___|
                ___|
            ___|
        ___|
    ___|
___|