Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Laba1CSharp
- {
- class Program
- {
- static void Main()
- {
- Console.OutputEncoding = Encoding.Unicode;
- int inputFigure;
- int vert, horizon; //Координаты фигуры
- int xCoord, yCoord;
- char[,] arrZero = new char[8, 8];
- Console.WriteLine("Добро пожаловать\nВас привутствует программа, располагающая шахматные фигуры на доске в произвольном месте\nНа данный момент разработаны комбинации лишь для 2 фигур: Ферзя(0) и Коня(1)\nПожалуйста, сделайте Ваш выбор : ");
- inputFigure = Convert.ToInt32(Console.ReadLine());
- if (inputFigure == 0) //Ferz
- {
- Console.WriteLine("Хороший выбор! Вы выбрали самую комбинаторную и опасную фигуру - Ферзь.");
- }
- else
- {
- Console.WriteLine("Horse");
- }
- Console.WriteLine("Пожалуйста, введите координаты фигуры на шахмотной доске: ");
- vert = Convert.ToInt32(Console.ReadLine());
- horizon = Convert.ToInt32(Console.ReadLine());
- xCoord = vert - 1;
- yCoord = horizon - 1;
- ArrConsist(xCoord, yCoord, arrZero, inputFigure);
- Console.ReadLine();
- }
- public static void ArrConsist(int y_Coord, int x_Coord, char[,] arr_Zero, int inputFigure)
- {
- for (int i = 0; i < 8; i++)
- {
- for (int j = 0; j < 8; j++)
- {
- arr_Zero[i, j] = ' ';
- }
- }
- if (inputFigure == 0)
- {
- Ferz(y_Coord, x_Coord, arr_Zero);
- }
- else Horse(y_Coord, x_Coord, arr_Zero);
- for (int i = 0; i < 8; i++)
- {
- for (int j = 0; j < 8; j++)
- {
- Console.BackgroundColor = ((i + j) % 2 == 0) ? ConsoleColor.White : ConsoleColor.DarkGray;
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.Write(arr_Zero[i, j] + " ");
- }
- Console.WriteLine();
- }
- }
- public static void Horse(int y_Coord, int x_Coord, char[,] arr_Zero)
- {
- for (int x = -2; x < 3; x++)
- {
- if (x_Coord + x >= 0 && x_Coord + x < 8)
- {
- if (Math.Abs(x) == 2)
- {
- if (y_Coord + 1 < 8) arr_Zero[y_Coord + 1, x + x_Coord] = '*';
- if (y_Coord - 1 >= 0) arr_Zero[y_Coord - 1, x + x_Coord] = '*';
- }
- else if (Math.Abs(x) == 1)
- {
- if (y_Coord + 2 < 8) arr_Zero[y_Coord + 2, x + x_Coord] = '*';
- if (y_Coord - 2 >= 0) arr_Zero[y_Coord - 2, x + x_Coord] = '*';
- }
- }
- }
- arr_Zero[y_Coord,x_Coord] = 'H';
- }
- public static void Ferz(int y_Coord, int x_Coord, char[,] arr_Zero)
- {
- for (int X_bias = -1; X_bias < 2 ; X_bias++)
- {
- for (int Y_bias = -1; Y_bias < 2; Y_bias++)
- {
- if (X_bias == 0 && Y_bias == 0) continue;
- for (int x = x_Coord, y = y_Coord; x < 8 && y >= 0 && y<8 && x>= 0; x+=X_bias, y+=Y_bias)
- arr_Zero[y, x] = '*';
- }
- }
- arr_Zero[y_Coord,x_Coord] = 'F';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement