Advertisement
koksibg

Sandglass_Second

Jul 30th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 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 Sandglass_Second
  8. {
  9.     class Sandglass_Second
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int N = int.Parse(Console.ReadLine());
  14.             int M = 1;
  15.             if (N % 2 != 0)
  16.             {
  17.                 for (int i = 1; i <= M; i++)
  18.                 {
  19.                     if (M <= N - i)
  20.                     {
  21.                         Console.WriteLine("{0}{1}{0}", new string(' ', i), new string('*', N - M - i));
  22.                         System.Threading.Thread.Sleep(1000);
  23.                         M++;
  24.                     }
  25.                 }
  26.                 for (int j = M; j >= 1; j--)
  27.                 {
  28.                     if (M < N - j)
  29.                     {
  30.                         M--;
  31.                         Console.WriteLine("{0}{1}{0}", new string(' ', j), new string('*', N - M - j + 1));
  32.                         System.Threading.Thread.Sleep(1000);
  33.                     }
  34.                 }
  35.             }
  36.             else
  37.             {
  38.                 for (int i = 1; i <= M; i++)
  39.                 {
  40.                     if (M <= N - i)
  41.                     {
  42.                         Console.WriteLine("{0}{1}{0}", new string(' ', i), new string('*', N - M - i + 1));
  43.                         System.Threading.Thread.Sleep(1000);
  44.                         M++;
  45.                     }
  46.                 }
  47.                 for (int j = M; j >= 0; j--)
  48.                 {
  49.                     if (M < N - j)
  50.                     {
  51.                         M--;
  52.                         Console.WriteLine("{0}{1}{0}", new string(' ', j + 1), new string('*', N - M - j + 1));
  53.                         System.Threading.Thread.Sleep(1000);
  54.  
  55.                     }
  56.                 }
  57.             }
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement