Categories
Visual C# Телерик

Задача: Kaspichania Boats

Решение

using System;

namespace KaspichaniaBoats {
  class Program {
    static void Main() {
      int n = int.Parse(Console.ReadLine());
      int boatWidth = 2 * n + 1;

      int dots = 1;
      for (int i = 0; i < n; i++) {
        Console.Write(new string('.', n - i));
        if (i == 0) {
          Console.Write(new string('*', 1));
        } else if (i == 1) {
          Console.Write(new string('*', 3));
        } else {
          Console.Write("*");
          Console.Write(new string('.', dots));
          Console.Write("*");
          Console.Write(new string('.', dots));
          Console.Write("*");
          dots++;
        }
        Console.Write(new string('.', n - i));
        Console.WriteLine();
      }
      Console.WriteLine(new string('*', boatWidth));
      int counter = 1;
      dots = n - 2;
      for (int i = 1; i <= n / 2; i++) {
        Console.Write(new string('.', i));
        Console.Write(new string('*', 1));
        Console.Write(new string('.', dots));
        Console.Write(new string('*', 1));
        Console.Write(new string('.', dots));
        Console.Write(new string('*', 1));
        Console.Write(new string('.', i));
        dots--;
        counter++;
        Console.WriteLine();
      }
      Console.Write(new string('.', counter));
      Console.Write(new string('*', boatWidth - 2 * counter));
      Console.Write(new string('.', counter));
    }
  }
}