Advertisement
fbinnzhivko

Boat

Mar 12th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.  
  8.         int number = int.Parse(Console.ReadLine());
  9.  
  10.         //draw sail
  11.         int sailCurrentW = 1;
  12.         bool middlePointReached = false;
  13.  
  14.         for (int c = 0; c < number; c++)
  15.         {
  16.             Console.WriteLine("{0}{1}{2}", new string('.', number - sailCurrentW), new string('*', sailCurrentW), new string('.', number));
  17.             if (sailCurrentW >= number)
  18.             {
  19.                 middlePointReached = true;
  20.             }
  21.             if (middlePointReached)
  22.             {
  23.                 sailCurrentW = sailCurrentW - 2;
  24.             }
  25.             else
  26.             {
  27.                 sailCurrentW = sailCurrentW + 2;
  28.             }
  29.  
  30.  
  31.         }
  32.         int dots = 0;   //draw boat
  33.         int boatHight = number / 2;
  34.         int boatWight = 2 * number;
  35.  
  36.         for (int row = 1; row <= boatHight; row++)
  37.         {
  38.             Console.WriteLine("{0}{1}{0}", new string('.', dots), new string('*', boatWight));
  39.             boatWight = boatWight - 2;
  40.             dots = dots + 1;
  41.  
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement