Advertisement
Venciity

[SoftUni C# exam preparation] 04.KaspichaniaBoats

Apr 2nd, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class KaspichaniaBoats
  8.     {
  9.         static void Main()
  10.         {
  11.             int n = Int32.Parse(Console.ReadLine());
  12.  
  13.             int width = n * 2 + 1;
  14.             int height = 6 + ((n - 3) / 2) * 3;
  15.  
  16.             int dotsBeforeAndAfter = n;
  17.             int stars = 1;
  18.  
  19.             Console.Write(new string('.', dotsBeforeAndAfter));
  20.             Console.Write(new string('*', stars));
  21.             Console.Write(new string('.', dotsBeforeAndAfter));
  22.             Console.WriteLine();
  23.  
  24.             int dotsBetween = 0;
  25.             dotsBeforeAndAfter--;
  26.  
  27.             do
  28.             {
  29.                 Console.Write(new string('.', dotsBeforeAndAfter));
  30.                 Console.Write(new string('*', stars));
  31.                 Console.Write(new string('.', dotsBetween));
  32.                 Console.Write(new string('*', stars));
  33.                 Console.Write(new string('.', dotsBetween));
  34.                 Console.Write(new string('*', stars));
  35.                 Console.Write(new string('.', dotsBeforeAndAfter));
  36.                 Console.WriteLine();
  37.                 dotsBetween++;
  38.                 dotsBeforeAndAfter--;
  39.             } while (dotsBeforeAndAfter > 0);
  40.  
  41.  
  42.             Console.WriteLine(new string('*', width));
  43.  
  44.             while (dotsBeforeAndAfter != dotsBetween)
  45.             {
  46.                 dotsBetween --;
  47.                 dotsBeforeAndAfter++;
  48.                 Console.Write(new string('.', dotsBeforeAndAfter));
  49.                 Console.Write(new string('*', stars));
  50.                 Console.Write(new string('.', dotsBetween));
  51.                 Console.Write(new string('*', stars));
  52.                 Console.Write(new string('.', dotsBetween));
  53.                 Console.Write(new string('*', stars));
  54.                 Console.Write(new string('.', dotsBeforeAndAfter));
  55.                 Console.WriteLine();
  56.             }
  57.  
  58.             // print final row
  59.             int finalStars = n;
  60.             int finalDots = (width - finalStars) / 2;
  61.  
  62.             Console.Write(new string('.', finalDots));
  63.             Console.Write(new string('*', finalStars));
  64.             Console.Write(new string('.', finalDots));
  65.         }
  66.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement