Advertisement
kalinkata

House with a Window

Jul 26th, 2014
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. using System;
  2.  
  3. class HouseWithWindow
  4. {
  5. static void Main()
  6. {
  7. int n = int.Parse(Console.ReadLine());
  8.  
  9. HouseTop(n);
  10. HouseRoof(n);
  11. HouseAndRoofBottom(n);
  12. HouseBase(n);
  13. HouseAndRoofBottom(n);
  14. }
  15.  
  16. private static void HouseBase(int n)
  17. {
  18. int dots = n * 2 - 3;
  19.  
  20. for (int i = 0; i < n / 4; i++)
  21. {
  22. Console.Write(new string('*', 1));
  23. Console.Write(new string('.', dots));
  24. Console.Write(new string('*', 1));
  25. Console.WriteLine();
  26. }
  27.  
  28. dots = n / 2;
  29. int windowWidth = n - 3;
  30.  
  31. for (int i = 0; i < n / 2; i++)
  32. {
  33. Console.Write(new string('*', 1));
  34. Console.Write(new string('.', dots));
  35. Console.Write(new string('*', windowWidth));
  36. Console.Write(new string('.', dots));
  37. Console.Write(new string('*', 1));
  38. Console.WriteLine();
  39. }
  40.  
  41. dots = n * 2 - 3;
  42.  
  43. for (int i = 0; i < n / 4; i++)
  44. {
  45. Console.Write(new string('*', 1));
  46. Console.Write(new string('.', dots));
  47. Console.Write(new string('*', 1));
  48. Console.WriteLine();
  49. }
  50. }
  51.  
  52. private static void HouseAndRoofBottom(int n)
  53. {
  54. int stars = 2 * n - 1;
  55. Console.WriteLine(new string('*', stars));
  56. }
  57.  
  58. private static void HouseRoof(int n)
  59. {
  60. int outerDots = n - 2;
  61. int innerDots = 1;
  62.  
  63. for (int i = 0; i < n - 1; i++)
  64. {
  65. Console.Write(new string('.', outerDots));
  66. Console.Write(new string('*', 1));
  67. Console.Write(new string('.', innerDots));
  68. Console.Write(new string('*', 1));
  69. Console.Write(new string('.', outerDots));
  70. Console.WriteLine();
  71.  
  72. outerDots--;
  73. innerDots += 2;
  74. }
  75. }
  76.  
  77. private static void HouseTop(int n)
  78. {
  79. Console.Write(new string('.', n - 1));
  80. Console.Write(new string('*', 1));
  81. Console.Write(new string('.', n - 1));
  82. Console.WriteLine();
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement