svetlozar_kirkov

Kaspichania Boats

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