Eriziel

Christmas Tree

Dec 21st, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.35 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 ConsoleApplication6
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.Write("Write x: ");
  14.             int i;
  15.             int j;
  16.             int k;
  17.             int x = Convert.ToInt32(Console.ReadLine());
  18.  
  19.             i = 0;
  20.             while(i < x)
  21.             {
  22.                 k = 0;
  23.                 while(k < x - 1 - i)
  24.                 {
  25.                     Console.Write("  ");
  26.                     k++;
  27.                 }
  28.  
  29.                 j = 0;
  30.                 while(j <=  2 * i)
  31.                 {
  32.                     Console.Write("* ");
  33.                     j++;
  34.                 }
  35.  
  36.                 Console.WriteLine();
  37.                 i++;
  38.             }
  39.  
  40.             i = 0;
  41.             while (i < x)
  42.             {
  43.                 k = 0;
  44.                 while (k < x - 1 - i)
  45.                 {
  46.                     Console.Write("  ");
  47.                     k++;
  48.                 }
  49.  
  50.                 j = 0;
  51.                 while (j <= 2 * i)
  52.                 {
  53.                     Console.Write("* ");
  54.                     j++;
  55.                 }
  56.  
  57.                 Console.WriteLine();
  58.                 i++;
  59.             }
  60.  
  61.             i = 0;
  62.             while (i < x)
  63.             {
  64.                 k = 0;
  65.                 while (k < x - 1 - i)
  66.                 {
  67.                     Console.Write("  ");
  68.                     k++;
  69.                 }
  70.  
  71.                 j = 0;
  72.                 while (j <= 2 * i)
  73.                 {
  74.                     Console.Write("* ");
  75.                     j++;
  76.                 }
  77.  
  78.                 Console.WriteLine();
  79.                 i++;
  80.             }
  81.             i = 0;
  82.             while (i < x)
  83.             {
  84.                 k = 0;
  85.                 while(k < x - 2)
  86.                 {
  87.                     Console.Write("  ");
  88.                     k++;
  89.                 }
  90.                 j = 0;
  91.                 while (j < x - 2)
  92.                 {
  93.                     Console.Write("* ");
  94.                     j++;
  95.                 }
  96.  
  97.                 Console.WriteLine();
  98.                 i++;
  99.             }
  100.  
  101.             Console.WriteLine("Press SPACE to EXIT");
  102.             Console.ReadKey();
  103.  
  104.         }
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment