Advertisement
Guest User

Question 3

a guest
Sep 1st, 2015
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 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 ConsoleApplication3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int width = int.Parse(Console.ReadLine());
  14.  
  15.             int height = (int)(width * 1.5);
  16.  
  17.             char one = '#';
  18.             char two = '.';
  19.  
  20.  
  21.  
  22.  
  23.             for (int i = 0; i < height; i++)
  24.             {
  25.  
  26.                 for (int j = 0; j < width; j++)
  27.                 {
  28.                     if ( i % 3 == 0 && j % 3 == 0)
  29.                     {
  30.                         Console.Write(one);
  31.                     }
  32.                     if (i % 3 == 0 && j % 3 != 0)
  33.                     {
  34.                         Console.Write(two);
  35.                     }
  36.                     if (i % 3 != 0 && (j + 1) % 3 == 0 && ( i + 1 ) % 3 != 0)
  37.                     {
  38.                         Console.Write(one);
  39.                     }
  40.                     if (i % 3 != 0 && (j + 1) % 3 != 0 && (i + 1) % 3 != 0)
  41.                     {
  42.                         Console.Write(two);
  43.                     }
  44.                     if ((i + 1) % 3 == 0 && ( j + 2) % 3 == 0)
  45.                     {
  46.                         Console.Write(one);
  47.                     }
  48.                     if ((i + 1) % 3 == 0 && (j + 2) % 3 != 0)
  49.                     {
  50.                         Console.Write(two);
  51.                     }
  52.  
  53.  
  54.                 }
  55.                 Console.WriteLine();
  56.  
  57.  
  58.             }
  59.  
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement