Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. class Program
  2.  
  3. {
  4.  
  5. private static readonly string[] letters = { "A", "B", "C", "D", "E", "F", "G", "H" };
  6.  
  7. private const int size = 8;
  8.  
  9. private static bool[,] chessboard;
  10.  
  11. private static void Main()
  12.  
  13. {
  14.  
  15. const string top = " -----------------";
  16.  
  17. //init chessboard
  18.  
  19. chessboard = new bool[size, size];
  20.  
  21. //place a figure on field 4/6 for demonstration
  22.  
  23. chessboard[4, 6] = true;
  24.  
  25. chessboard[5, 6] = true;
  26.  
  27. for (int y = 0; y < size; y++)
  28.  
  29. {
  30.  
  31. Console.WriteLine(" {0}", top);
  32.  
  33. Console.Write("{0} ", size - y);
  34.  
  35. for (int x = 0; x < size; x++)
  36.  
  37. {
  38.  
  39. Console.Write("|{0}", chessboard[x, y] ? 'X' : ' ');
  40.  
  41. }
  42.  
  43. Console.WriteLine("|");
  44.  
  45. }
  46.  
  47. Console.Write(" ");
  48.  
  49. for (int i = 0; i < size; i++)
  50.  
  51. {
  52.  
  53. Console.Write("{0} ", letters[i]);
  54.  
  55. }
  56.  
  57. Console.ReadKey();
  58.  
  59. }
  60.  
  61. }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement