Весела Коледа и успешна нова 2017-та година!


6
namespace ChristmasTree { using System; using System.Text; class Startup { static void Main() { Console.OutputEncoding = Encoding.Unicode; Start(); } public static void Start() { Console.WriteLine("Input tree size:"); try { Console.WriteLine(GetChristmasTree(uint.Parse(Console.ReadLine()))); } catch (ArgumentException) { Console.WriteLine("You deserve a bigger tree!"); Start(); } } public static string GetChristmasTree(uint treeSize) { if (treeSize<5) { throw new ArgumentException(); } var result = new StringBuilder(); int count = 0; result.AppendLine($"Merry Christmas!{Environment.NewLine}Happy New Year!"); result.AppendLine(new string(' ', (int)(treeSize - 1)) + '\u22C6'); for (int i = 0; i < treeSize; i++) { for (int x = 0; x < treeSize - i - 1; x++) { result.Append(" "); } for (int j = 0; j < i * 2 + 1; j++) { result.Append("*"); } result.AppendLine(); } for (int i = 0; i < 4; i++) { for (int x = 0; x < treeSize - count - 1; x++) { result.Append(" "); } result.AppendLine("X"); } result.AppendLine("May the code be with you during 2017!"); return result.ToString(); } } }
Compile this code(C#)



Отговори



2
Весела Коледа и щастлива Нова година! :-)

от g_nikolaev (10 точки)