Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Введите 8 маршрутов:");
            Marsh[] marshes = new Marsh[8];
            for (int i = 0; i < 8; i++)
            {
                Console.Write("Начальный пункт: ");
                marshes[i].start = Console.ReadLine();
                Console.Write("Конечный пункт: ");
                marshes[i].finish = Console.ReadLine();
                Console.Write("Номер маршрута: ");
                marshes[i].number = int.Parse(Console.ReadLine());
            }

            Marsh temp = new Marsh();

            for (int j = 0; j < 7; j++)
            {
                for (int i = 0; i < 6; i++)
                {
                    if (marshes[i].number > marshes[i + 1].number)
                    {
                        temp           = marshes[i];
                        marshes[i]     = marshes[i + 1];
                        marshes[i + 1] = temp;
                    }
                }
            }

            Console.Write("Введите номер маршрута: ");
            int  numb  = int.Parse(Console.ReadLine());
            bool find  = false;
            int  count = 1;

            for (int i = 0; i < 7; i++)
            {
                if (marshes[i].number == numb)
                {
                    find = true;
                    break;
                }
            }
            if (find)
            {
                for (int i = 0; i < 7; i++)
                {
                    if (marshes[i].number == numb)
                    {
                        Console.WriteLine("{0}: Маршрут №{1}: Точка начала - {2}, Точка окончания - {3}", count, numb, marshes[i].start, marshes[i].finish);
                    }
                    count++;
                }
            }
            else
            {
                Console.WriteLine("Маршруты с таким номером отсутствуют");
            }

            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Marsh marsh = new Marsh();

            Console.OutputEncoding = Encoding.Unicode;

            //encrypt
            int    key = 6;
            String msg = "";

            long OldTicks = DateTime.Now.Ticks;

            using (StreamReader sr = new StreamReader("in.txt"))
            {
                msg = (sr.ReadToEnd());
                msg = msg.Replace(" ", "");
            }


            string result_marsh = marsh.Encrypt(msg, key);

            Console.WriteLine("\nИсходный текст:  " + msg);
            Console.WriteLine("Маршрутный шифр: " + result_marsh);
            Console.WriteLine("Расшифров текст: " + marsh.Decrypt(result_marsh, key));

            long time_cipher = (DateTime.Now.Ticks - OldTicks) / 1000;

            Console.WriteLine("Затрачено " + time_cipher + " мс\n\n\n\n");



            /*
             *  юлия чистякова
             *  2103 725683410
             */
            Mnozh mnozh = new Mnozh();

            int[] key1 = { 2, 1, 0, 3 };
            int[] key2 = { 7, 2, 5, 6, 8, 3, 4, 1, 0 };
            OldTicks = DateTime.Now.Ticks;

            string result_mnozh = mnozh.Encrypt(msg, key1, key2);

            Console.WriteLine("Исходный текст:  " + msg);
            Console.WriteLine("Множеств шифр:   " + result_mnozh);
            Console.WriteLine("Расшифров текст: " + mnozh.Decrypt(result_mnozh, key2, key1));

            time_cipher = (DateTime.Now.Ticks - OldTicks) / 1000;
            Console.WriteLine("Затрачено " + time_cipher + " мс");



            Console.ReadKey();
        }
Beispiel #3
0
        internal Tek GetResult()
        {
            var tekId = NTekAppPkg.CreateTek(connection, Nc, Obozn);

            NTekAppPkg.SetWorkTek(connection, tekId);

            QM.Update(connection, "N_TEK", tekId, "NAIM_ID", NaimId);

            var marshid = QM.Insert(connection, "insert into tpp.n_marsh(n_tek_id, spr_oper_id, npp) values (:0, :1, :2)  returning n_marsh_id into :id", new object[] { tekId, SprOperId, 1 });

            var marsh = new Marsh(connection, marshid);

            marsh.AddObor(SprOborId, true);


            return(new Tek(connection, tekId));
        }
Beispiel #4
0
        private void GenerateRectangleIsland(Rectangle island)
        {
            var random   = new Random();
            int distance = 1;
            var tiles    = _world.GetTilesInRectangle(island);

            foreach (var tile in tiles)
            {
                //
                if (tile.Y > _world.Height - 5)
                {
                    var winter = new Tundra(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(winter, tile.X, tile.Y, true, true, false);
                }
                else if (tile.Y > _world.Height - 10)
                {
                    var desert = new Dessert(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(desert, tile.X, tile.Y, true, true, false);
                }
                else if (tile.Y < 5)
                {
                    var winter = new Tundra(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(winter, tile.X, tile.Y, true, true, false);
                }
                else if (tile.Y < 10)
                {
                    var desert = new Dessert(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(desert, tile.X, tile.Y, true, true, false);
                }
                else
                {
                    var tileType = random.Next(0, 99);
                    if (tileType < 30)
                    {
                        var plains = new Plains(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(plains, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 50)
                    {
                        var Forest = new Plains(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(Forest, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 65)
                    {
                        var hill = new Hills(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(hill, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 75)
                    {
                        var mountain = new Mountain(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(mountain, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 90)
                    {
                        var marsh = new Marsh(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(marsh, tile.X, tile.Y, true, true, false);
                    }
                    else
                    {
                        var plain = new Plains(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(plain, tile.X, tile.Y, true, true, false);
                    }
                }
            }

            var beachTiles =
                _world.GetTilesAlongLine(island.Left - distance, island.Top - distance, island.Right, island.Top - distance).ToList();

            beachTiles.
            AddRange(_world.GetTilesAlongLine(island.Left - distance, island.Bottom, island.Right, island.Bottom));
            beachTiles.
            AddRange(_world.GetTilesAlongLine(island.Left - distance, island.Top - distance, island.Left - distance, island.Bottom));
            beachTiles.
            AddRange(_world.GetTilesAlongLine(island.Right, island.Top - distance, island.Right, island.Bottom));
            foreach (var t in beachTiles)
            {
                var coast = new Coast(t.X, t.Y, t.Cell);
                _world.SetTileProperty(coast, t.X, t.Y, true, true, false);
            }
        }