Advertisement
sashomaga

logo

Dec 30th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         int x = int.Parse(Console.ReadLine());
  9.         int z = x / 2 + 1;
  10.         int length = 3*x - 2;
  11.         int height = length;
  12.  
  13.         z = z - 1; //coz of zero
  14.         for (int j = 0; j < length; j++) //rows
  15.         {
  16.             for (int i = 0; i < length; i++) //cols
  17.             {
  18.                 if (i == z - j)
  19.                 {
  20.                     Console.Write("*");
  21.                 }
  22.                 else if((i == z + j)&&(j < 2*x-1))
  23.                 {
  24.                     Console.Write("*");
  25.                 }
  26.                 else if((i==length - z - j -1)&&(j< 2*x-1))
  27.                 {
  28.                     Console.Write("*");
  29.                 }
  30.                 else if(i == length - z + j -1)
  31.                 {
  32.                     Console.Write("*");
  33.                 }
  34.                 else if ((i == z+j+1 -(x*2-1)) && (j >= 2 * x - 1)) //last
  35.                 {
  36.                     Console.Write("*");
  37.                 }
  38.                 else if ((i == length - z -j-2 +(x*2-1)) && (j >= 2 * x - 1)) //last right
  39.                 {
  40.                     Console.Write("*");
  41.                 }
  42.                 else
  43.                 {
  44.                     Console.Write(".");
  45.                 }
  46.                
  47.             }
  48.             Console.WriteLine();
  49.         }
  50.        
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement