コード例 #1
0
ファイル: Program.cs プロジェクト: LeThanhTai98/BT_LOP
        static void Main(string[] args)
        {
            //// truong hop 1

            long   bg = (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
            vessel a  = new vessel();
            int    n;

            storage b = new storage();


            nhapfile nhap = new nhapfile();

            nhap.FileName = "demo2.txt";
            nhap.ReadData();
            if (nhap.Containers != 0)
            {
                int column;
                column = nhap.Column;
                List <Stack <int> > stackss = new List <Stack <int> >();
                a.A1 = nhap.Stacks;
                Console.WriteLine("dau vao ");
                a.showvessel();
                int so_hang_ben_storage = nhap.Heightyard;
                n = a.totalvessel(so_hang_ben_storage);
                for (int i = 0; i <= n; i++)
                {
                    List <double> tam = a.grab1(so_hang_ben_storage);
                    b.catching(tam);

                    b.sapxep();
                }
                Console.WriteLine("sap xep nhu sau");

                long end = (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;

                nhap.saveFile(b, "ketqua.txt", (end - bg) * 0.001);
            }
            Console.ReadKey();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: LeThanhTai98/BT_LOP
        static void Main(string[] args)
        {
            long     bg = (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
            vessel   a  = new vessel();
            int      n;
            storage  b    = new storage();
            temp     c    = new temp();
            nhapfile nhap = new nhapfile();

            nhap.FileName = "retest2.txt";
            nhap.ReadData();
            if (nhap.Containers != 0)
            {
                if (nhap.Trung == 0)
                {
                    a.A1 = nhap.Stacks;
                    Console.WriteLine("dau vao ");
                    a.showvessel();
                    int x;
                    if (nhap.Heightyard > nhap.Column)
                    {
                        x = nhap.Column;
                    }
                    else
                    {
                        x = nhap.Heightyard;
                    }

                    while (a.totalvessel() != 0)
                    {
                        List <container> tam  = a.grab2(x, nhap);
                        List <container> tam1 = new List <container>()
                        {
                            new container()
                        };

                        tam.Sort((z, y) => y.Sohieu.CompareTo(z.Sohieu));
                        //while (tam.Count < nhap.Heightyard && tam1.Count != 0)
                        //{

                        //    tam1 = a.grabbehonM(tam[tam.Count - 1].Sohieu, nhap.Heightyard - 1 - tam.Count);
                        //    foreach(container cont in tam1)
                        //    {
                        //        Console.WriteLine(cont.Sohieu);
                        //        tam.Add(cont);
                        //    }
                        //}
                        //tam.Sort((z, y) => y.Sohieu.CompareTo(z.Sohieu));


                        if (tam.Count != 0)
                        {
                            b.catching(tam);
                            b.sapxep();
                        }
                    }
                    long end = (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
                    nhap.saveFile(b, a, c, "ketqua.txt", (end - bg) * 0.001);
                }
                else
                {
                    Console.WriteLine(" trung container ko xu li");
                }
            }
            Console.ReadKey();
        }