예제 #1
0
        //проверка наложения друг на друга
        static public bool Buter(sam[] masProv, sam prov)
        {
            bool peresechenir = false;
            int  ax1          = prov.aw;
            int  ay1          = prov.al;
            int  ax2          = prov.aw + prov.w;
            int  ay2          = prov.al + prov.l;


            for (int i = 0; i < masProv.Length; i++)
            {
                if (true)
                {
                    int bx1 = masProv[i].aw;
                    int by1 = masProv[i].al;
                    int bx2 = masProv[i].aw + masProv[i].w;
                    int by2 = masProv[i].al + masProv[i].l;

                    bool s1 = ((ax1 > bx1) && (ax1 < bx2)) || ((ax2 > bx1 && ax2 < bx2));
                    bool s2 = ((ay1 > by1) && (ay1 < by2)) || ((ay2 > by1 && ay2 < by2));
                    bool s3 = ((bx1 > ax1) && (bx1 < ax2)) || ((bx2 > ax1 && bx2 < ax2));
                    bool s4 = ((by1 > ay1) && (by1 < ay2)) || ((by2 > ay1 && by2 < ay2));

                    //peresechenir = !((ay1 > by2) || (ay2 < by1) || (ax2 < bx1) || (ax1 > bx2));

                    peresechenir = (s1 && s2) || (s3 && s4) || (s2 && s3) || (s1 || s4);
                    peresechenir = (s1 && s2) || (s3 && s4) || (s2 && s3) || (s1 || s4);
                    if (peresechenir)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var a = new sam
            {
                MyProperty  = 10,
                sMyProperty = "haha",
                ilist       = new List <int> {
                    2, 33434, 3234
                },
                slist = new List <string> {
                    "ajfaf", "ajdfj"
                }
            };
            var ss = Newtonsoft.Json.JsonConvert.SerializeObject(a);

            Console.WriteLine("Hello World!");
            Console.WriteLine(ss);
        }
예제 #3
0
        //обнуление и заполнение переменных

        //алгоритм поиска
        static public void sort(int look, point[] t, sam[] masGood, long kof, int newSum1)
        {
            iter++;
            //if (iter > stopIter) return;
            if (combo > 10000000)
            {
                return;
            }

            if (look < 1)
            {
                combo++;

                for (int i = 0; i < masGood.Length; i++)
                {
                    newSum = newSum + masGood[i].s;
                }

                if (newSum > sum)
                {
                    sum = newSum;
                    //if (combo > kof) return;
                    masSamReady = new sam[masGood.Length];
                    for (int k = 0; k < masGood.Length; k++)
                    {
                        masSamReady[k] = masGood[k];
                    }
                    newSum = 0;
                }
                newSum = 0;
                return;
            }

            for (int i = masSam.Length - look; i < masSam.Length; i++)
            {
                for (int v = 0; v < t.Length; v++)
                {
                    if ((masSam[i].h > an.h) || (masSam[i].w + t[v].w > an.w) || (masSam[i].l + t[v].l > an.l))
                    {
                        look--;
                        sort(look, t, masGood, kof, newSum);
                        look++;
                    }
                    else
                    {
                        sam buf = new sam();
                        buf    = masSam[i];
                        buf.aw = t[v].w;
                        buf.al = t[v].l;

                        if (!Buter(masGood, buf))
                        {
                            point[] tnew = new point[t.Length + 2];

                            byte pl = 0;
                            for (int y = 0; y < t.Length; y++)
                            {
                                if (y == v)
                                {
                                    pl = 1; continue;
                                }
                                tnew[y - pl] = t[y];
                            }
                            tnew[tnew.Length - 3].w = buf.w + 1 + buf.aw;
                            tnew[tnew.Length - 3].l = buf.l + buf.al + 1;
                            tnew[tnew.Length - 2].w = buf.w + 1 + buf.aw;
                            tnew[tnew.Length - 2].l = buf.al;
                            tnew[tnew.Length - 1].l = buf.l + buf.al + 1;
                            tnew[tnew.Length - 1].w = buf.aw;

                            sam[] newMasGood = new sam[masGood.Length + 1];

                            // if(masGood.Length > 0)
                            for (int k = 0; k < masGood.Length; k++)
                            {
                                newMasGood[k] = masGood[k];
                            }

                            newMasGood[newMasGood.Length - 1] = buf;
                            //newSum = newSum + buf.s;


                            look--;
                            sort(look, tnew, newMasGood, kof, newSum);
                            look++;
                            //newSum = newSum - buf.s;
                            // break;
                        }
                        else
                        {
                            look--;
                            sort(look, t, masGood, kof, newSum);
                            look++;
                        }
                    }
                }
            }
        }