Advertisement
iliqnvidenov

Untitled

Jan 28th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. class Boat
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         int currentwidth = 1;
  9.         bool middleReached = false;
  10.  
  11.         for (int i = 0; i < n; i++)
  12.         {
  13.             Console.Write(new string ('.',n - currentwidth));
  14.             Console.Write(new string('*', currentwidth));
  15.             Console.WriteLine(new string('.', n));
  16.             if (currentwidth >= n)
  17.             {
  18.                 middleReached = true;
  19.             }
  20.             if (middleReached)
  21.             {
  22.                 currentwidth -= 2;
  23.             }
  24.             else
  25.             {
  26.                 currentwidth += 2;
  27.             }
  28.         }
  29.  
  30.         int boatH = (n - 1) / 2;
  31.         int dots = 0;
  32.         for (int i = 0; i < boatH; i++,dots++,n--)
  33.         {
  34.             Console.Write(new string('.',dots));
  35.             Console.Write(new string('*',n*2));
  36.             Console.WriteLine(new string('.',dots));
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement