Advertisement
ivan_yosifov

Kaspichania_Boats

Dec 9th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.91 KB | None | 0 0
  1. using System;
  2.  
  3. class KaspichaniaBoats
  4. {
  5.     static void Main()
  6.     {
  7.         int N = int.Parse(Console.ReadLine());
  8.         int width = (N * 2) + 1;
  9.         int height = 6 + ((N - 3) / 2) * 3;
  10.         int sailHeight = height * 2 / 3;
  11.         int bottomHeight = height * 1 / 3;
  12.        
  13.         // print top(sail) part
  14.         for (int i = 0; i < sailHeight; i++)
  15.         {
  16.             if (i == sailHeight - 1)
  17.             {
  18.                 Console.Write(new string('*', width));
  19.             }
  20.             else
  21.             {
  22.                 int starPos = i - 1;
  23.                 for (int j = N - 1; j >= 0; j--)
  24.                 {
  25.                     if (starPos == j) Console.Write('*');
  26.                     else Console.Write('.');
  27.                 }
  28.                 Console.Write('*');
  29.                 for (int j = 0; j < N; j++)
  30.                 {
  31.                     if (starPos == j) Console.Write('*');
  32.                     else Console.Write('.');
  33.                 }
  34.             }
  35.             Console.WriteLine();
  36.         }
  37.  
  38.         // print bottom(base) part
  39.         for (int i = 0; i < bottomHeight; i++)
  40.         {
  41.             if (i == bottomHeight - 1)
  42.             {
  43.                 int dots = (width - N) / 2;
  44.                 Console.Write(new string('.', dots) +
  45.                     new string('*', N) + new string('.', dots));
  46.             }
  47.             else
  48.             {
  49.                 int starPos = i + 1;
  50.                 for (int j = 0; j < N; j++)
  51.                 {
  52.                     if (starPos == j) Console.Write('*');
  53.                     else Console.Write('.');
  54.                 }
  55.                 Console.Write('*');
  56.                 for (int j = N - 1; j >= 0; j--)
  57.                 {
  58.                     if (starPos == j) Console.Write('*');
  59.                     else Console.Write('.');
  60.                 }
  61.             }
  62.             Console.WriteLine();
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement