Advertisement
dimipan80

Telerik Exam. Kaspichania Boats

Jun 24th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. namespace _4.KaspichaniaBoats
  2. {
  3.     using System;
  4.  
  5.     public class KaspichaniaBoats
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             checked
  10.             {
  11.                 int num = int.Parse(Console.ReadLine());
  12.  
  13.                 int width = (2 * num) + 1;
  14.                 int height = 6 + (((num - 3) / 2) * 3);                
  15.                 for (int row = 0; row < height; row++)
  16.                 {
  17.                     for (int col = 0; col < width; col++)
  18.                     {
  19.                         if (row == num || col == num || (row == height - 1 && col >= num - (num / 2) && col <= num + (num / 2)))
  20.                         {
  21.                             Console.Write("*");
  22.                         }
  23.                         else if (col == row - num || col == (width - 1) - (row - num) || col == num - row || col == num + row)
  24.                         {
  25.                             Console.Write("*");
  26.                         }
  27.                         else
  28.                         {
  29.                             Console.Write(".");
  30.                         }
  31.                     }
  32.  
  33.                     Console.WriteLine();
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement