VanessaShopping

Exam 17 July

Jul 18th, 2016
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.67 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. namespace Diamond
  8. {
  9.     class Diamond
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int topDots = n - 1;
  15.             int moreDots = n * 3;
  16.             int bottomDots = 1;
  17.             int moreBottomDots = 5 * n - 4;
  18.             int formulaDots = 2 * n + 1;
  19.  
  20.             topPicture(n);
  21.             TopMiddlePicture(n, ref topDots, ref moreDots);
  22.             Console.WriteLine(new string('*', 5 * n));
  23.             BottomMiddlePicture(n, ref bottomDots, ref moreBottomDots);
  24.  
  25.             Console.Write(new string('.', formulaDots));
  26.             Console.Write(new string('*', n - 2));
  27.             Console.Write(new string('.', formulaDots));
  28.  
  29.         }
  30.  
  31.         private static void BottomMiddlePicture(int n, ref int bottomDots, ref int moreBottomDots)
  32.         {
  33.             if (n % 2 == 0)
  34.             {
  35.                 for (int i = 1; i < 2 * n + 1; i++)
  36.                 {
  37.                     Console.Write(new string('.', bottomDots));
  38.                     Console.Write("*");
  39.                     Console.Write(new string('.', moreBottomDots));
  40.                     Console.Write("*");
  41.                     Console.WriteLine(new string('.', bottomDots));
  42.                     bottomDots++;
  43.                     moreBottomDots -= 2;
  44.                 }
  45.             }
  46.             else
  47.             {
  48.                 for (int i = 1; i < 2 * n + 1; i++)
  49.                 {
  50.                     Console.Write(new string('.', bottomDots));
  51.                     Console.Write("*");
  52.                     Console.Write(new string('.', moreBottomDots));
  53.                     Console.Write("*");
  54.                     Console.WriteLine(new string('.', bottomDots));
  55.                     bottomDots++;
  56.                     moreBottomDots -= 2;
  57.                 }
  58.             }
  59.         }
  60.  
  61.         private static void TopMiddlePicture(int n, ref int topDots, ref int moreDots)
  62.         {
  63.             for (int i = 1; i < n; i++)
  64.             {
  65.  
  66.                 Console.Write(new string('.', topDots));
  67.                 Console.Write("*");
  68.                 Console.Write(new string('.', moreDots));
  69.                 Console.Write("*");
  70.                 Console.WriteLine(new string('.', topDots));
  71.                 topDots--;
  72.                 moreDots += 2;
  73.             }
  74.         }
  75.  
  76.         private static void topPicture(int n)
  77.         {
  78.             Console.Write(new string('.', n));
  79.             Console.Write(new string('*', n * 3));
  80.             Console.WriteLine(new string('.', n));
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment