stefan1919

draw star

Jul 31st, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6.  
  7. namespace novo2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int innerPoints;
  15.             int outerPoints;
  16.             for (int i = 0; i < (n / 2); i++)
  17.             {
  18.                 string outerDots = new string('.', n - i);
  19.                 if (i == 0)
  20.                 {
  21.                     Console.WriteLine(outerDots + "*" + outerDots);
  22.                 }
  23.                 else
  24.                 {
  25.                     string innerDots = new string('.', 2 * i - 1);
  26.                     Console.WriteLine(outerDots + "*" + innerDots + "*" + outerDots);
  27.                 }
  28.             }
  29.             for (int j = 0; j < n / 2; j++)
  30.             {
  31.                 string innerDotsFirstLine = new string('.', n - 1);
  32.                 string stars = new string('*', (n + 2) / 2);
  33.                 string outerDots = new string('.', j);
  34.                
  35.                 if (j == 0)
  36.                 {
  37.                     Console.WriteLine(stars + innerDotsFirstLine + stars);
  38.                 }
  39.                 else
  40.                 {
  41.                     string innerDots = new string('.', 2 * n + 1 - 2 - 2 * j);
  42.                     Console.WriteLine(outerDots + "*" + innerDots + "*" +  outerDots);
  43.                 }
  44.                
  45.             }
  46.             for (int h = 0; h < n / 2 + 1; h++)
  47.             {
  48.                 string outerDotsFirstLine = new string('.', n / 2);
  49.                 string innerDots = new string('.', n / 2 - 1);
  50.                  if (h == 0)
  51.                 {
  52.                     Console.WriteLine(outerDotsFirstLine + "*" + innerDots + "*" + innerDots + "*" + outerDotsFirstLine);
  53.                 }
  54.                 if (h == n / 2)
  55.                 {
  56.                    string starsLastLine = new string('*', n / 2 + 1);
  57.                  string innerInnerDots = new string('.', 2 * h - 1);
  58.                     Console.WriteLine(starsLastLine + innerInnerDots + starsLastLine);  
  59.                 }
  60.                
  61.                 if(h != 0 && h != n / 2)
  62.                 {
  63.                     string innerInnerDots = new string('.', Math.Abs( 2 * h - 1));
  64.                     string outerDots = new string('.', Math.Abs ( n / 2 - h));
  65.                     Console.WriteLine( outerDots + "*" + innerDots + "*" + innerInnerDots + "*" + innerDots +"*" + outerDots);
  66.                 }
  67.             }
  68.             }
  69.         }
  70.     }
Advertisement
Add Comment
Please, Sign In to add comment