Beispiel #1
0
        public static long SolveProblem2()
        {
            var zeroToOne = new Queue <long>();
            var oneToZero = new Queue <long>();

            var prog0 = new Prog(0, oneToZero, zeroToOne);
            var prog1 = new Prog(1, zeroToOne, oneToZero);

            var prog0State = ProgState.ready;
            var prog1State = ProgState.ready;

            while (true)
            {
                if (((prog0State == ProgState.waitingForQueue &&
                      oneToZero.Count() == 0) ||
                     prog0State == ProgState.terminated) &&
                    ((prog1State == ProgState.waitingForQueue &&
                      zeroToOne.Count() == 0) ||
                     prog1State == ProgState.terminated))
                {
                    return(prog1.sendCount);
                }
                prog0State = prog0.Run();
                prog1State = prog1.Run();
            }
        }
Beispiel #2
0
        public void M1Test()
        {
            Prog myProg  = new Prog();
            C    myParam = new C();

            Assert.AreEqual(3, myProg.M1(myParam));
        }
Beispiel #3
0
        public List <Order> GetOrder()
        {
            var getList = new Prog();
            var list    = getList.ReadOrder();

            return(list);
        }
        protected void Application_Start()
        {
            Prog prog = Prog.Current;

            Prog.Database.Initialize();

            Misc.Log("Application_Start");

            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //this.Error += delegate (object sender, EventArgs e)
            //{
            //    Logger.Log(HttpContext.Current.Error.GetBaseException().ToString());
            //    HttpContext.Current.Response.Redirect("~/Home/IPNotFound");
            //};

            //this.BeginRequest += delegate (object sender, EventArgs e)
            //{
            //    Logger.Log(null, "BeginRequest");
            //};
        }
Beispiel #5
0
        public List <Road> GetRoad()
        {
            var getList = new Prog();
            var list    = getList.ReadRoad();

            return(list);
        }
Beispiel #6
0
 public override void Visit(Prog n)
 {
     foreach (AST ast in n.prog)
     {
         ast.accept(this);
     }
 }
Beispiel #7
0
        private static int GroupSize(Prog root, IReadOnlyDictionary <string, Prog> progs, int groupId)
        {
            var q = new Queue <Prog>();

            q.Enqueue(root);

            var seen  = new HashSet <string>();
            var count = 0;

            while (q.Count > 0)
            {
                var p = q.Dequeue();

                p.GroupId = groupId;

                seen.Add(p.Id);

                foreach (var nb in p.Neighbours.Select(x => progs[x]).Where(x => !seen.Contains(x.Id)))
                {
                    q.Enqueue(nb);
                }

                count++;
            }

            return(count);
        }
        public static void Main(string[] args)
        {
            int  binary1, binary2, multiply = 0;
            int  digit, factor = 1;
            Prog pg = new Prog();

            Console.WriteLine("Enter the first binary number: ");
            binary1 = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter the second binary number: ");
            binary2 = int.Parse(Console.ReadLine());
            while (binary2 != 0)
            {
                digit = binary2 % 10;
                if (digit == 1)
                {
                    binary1  = binary1 * factor;
                    multiply = pg.Binaryproduct(binary1, multiply);
                }
                else
                {
                    binary1 = binary1 * factor;
                    binary2 = binary2 / 10;
                    factor  = 10;
                }
                Console.WriteLine("Product of two binary numbers: {0}", multiply);
                Console.ReadLine();
            }
        }
Beispiel #9
0
        public void T(int n, int m)
        {
            NumberOfComands++;
            string comand = NumberOfComands.ToString() + ". T(" + n.ToString() + "," + m.ToString() + ")";

            Prog.Add(comand);
        }
Beispiel #10
0
        public EditProgWindow(ProgList progList, int id = -1)
        {
            InitializeComponent();
            this.AcceptButton = this.saveButton;
            this.CancelButton = this.cancelButton;
            _progList         = progList;

            if (!JumpListHelper.IsSupported())
            {
                jumpListLabel.Hide();
                jumpListLabelState.Hide();
                jumpListBox.Hide();
            }

            if (id < 0)
            {
                this.Text = Localization.Strings.AddProgram;
                _prog     = _progList.CreateProg();
                _isNew    = true;
            }
            else
            {
                this.Text                = Localization.Strings.EditProgram;
                _prog                    = progList.Get(id);
                _isNew                   = false;
                this.nameField.Text      = _prog.Name;
                this.pathField.Text      = _prog.Path;
                this.argsField.Text      = _prog.Args;
                this.diskImageField.Text = _prog.DiskImage;
                this.iconField.Text      = _prog.Icon;
                this.jumpListBox.Checked = _prog.InJumpList;

                updateIconPreview();
            }
        }
Beispiel #11
0
        public void S(int n)
        {
            NumberOfComands++;
            string comand = NumberOfComands.ToString() + ". S(" + n.ToString() + ")";

            Prog.Add(comand);
        }
Beispiel #12
0
        public void J(int n, int m, int k)
        {
            NumberOfComands++;
            string comand = NumberOfComands.ToString() + ". J(" + n.ToString() + "," + m.ToString() + "," + k.ToString() + ")";

            Prog.Add(comand);
        }
Beispiel #13
0
        public List <Category> GetCategory()
        {
            var getList = new Prog();
            var list    = getList.ReadCategory();

            return(list);
        }
Beispiel #14
0
    static void Main()
    {
        string text = Prog.GetText();

        System.Console.WriteLine(text.Length);
        System.Console.WriteLine(text.ToUpper());
    }
Beispiel #15
0
        public void Part2(string input)
        {
            var          commands = Parse(input).ToList();
            Queue <long> q0 = new Queue <long>(), q1 = new Queue <long>();
            var          p0 = new Prog(commands, new Dictionary <string, long> {
                ["p"] = 0
            }, q0, q1);
            var p1 = new Prog(commands, new Dictionary <string, long> {
                ["p"] = 1
            }, q1, q0);

            while (true)
            {
                p0.Run();
                p1.Run();

                if ((p0.BlockedCount > 1 && p1.BlockedCount > 1) ||
                    (p0.Terminated && (p1.Terminated || p1.BlockedCount > 0)) ||
                    (p1.Terminated && (p0.Terminated || p0.BlockedCount > 0)))
                {
                    break;
                }
            }

            Console.WriteLine("Result: " + p1.CountSnd);
        }
        static public void Create_Vklad(Client client, Valute valute, Prog prog, decimal Sum, Schet Out, Bank bank)
        {
            Schet In = new Schet();

            In.Nschet    = 1;
            In.Data_sozd = DateTime.Now;
            In.Prog      = prog;
            In.Sum       = 0;
            In.ValuteID  = valute.ID;
            In.ClientID  = client.ID;
            In.Status    = true;
            bank.Schet.Add(In);
            bank.SaveChanges();
            Operacii operacii = new Operacii();

            operacii.ID             = 1;
            operacii.Date           = DateTime.Now;
            operacii.StatusID       = bank.Status.Where(i => i.Name == "Выполнена").FirstOrDefault().ID;
            operacii.OutID          = Out.Nschet;
            operacii.InID           = In.Nschet;
            operacii.Tip_operaziiID = bank.Tip_operacii.Where(i => i.Name == "Создание вклада").FirstOrDefault().ID;
            if (In.ValuteID == Out.ValuteID)
            {
                operacii.Sum_In = operacii.Sum_Out = Sum;
                Out.Sum        -= Sum;
                In.Sum         += Sum;
            }
            else
            {
                perevod(Out, In, Sum, bank, operacii);
            }

            bank.Operacii.Add(operacii);
            bank.SaveChanges();
        }
        public async Task <ActionResult <Prog> > PostProg(Prog prog)
        {
            _context.Prog.Add(prog);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProg", new { id = prog.ProgId }, prog));
        }
        public async Task <IActionResult> PutProg(int id, Prog prog)
        {
            if (id != prog.ProgId)
            {
                return(BadRequest());
            }

            _context.Entry(prog).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProgExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        static public void Create_Kredit(Schet schet, Prog prog, decimal Sum, Bank bank, Valute valute, int client)
        {
            bank.Prog.Add(prog);
            bank.SaveChanges();
            Schet schet1 = new Schet();

            schet1.ClientID  = client;
            schet1.Nschet    = 1;
            schet1.Data_sozd = DateTime.Now;
            schet1.ProgID    = prog.ID;
            schet1.Sum       = 0;
            schet1.Status    = false;
            schet1.ValuteID  = valute.ID;
            bank.Schet.Add(schet1);
            bank.SaveChanges();
            Operacii operacii = new Operacii();

            operacii.ID             = 1;
            operacii.Date           = DateTime.Now;
            operacii.StatusID       = bank.Status.Where(i => i.Name == "Ожидает выполнения").FirstOrDefault().ID;
            operacii.OutID          = schet1.Nschet;
            operacii.InID           = schet.Nschet;
            operacii.Tip_operaziiID = bank.Tip_operacii.Where(i => i.Name == "Создание кредита").FirstOrDefault().ID;
            operacii.Sum_In         = operacii.Sum_Out = Sum;
            bank.Operacii.Add(operacii);

            bank.SaveChanges();
        }
Beispiel #20
0
        public void CheckCarMethodShare()
        {
            double need = 10;
            Car    car  = new Prog(20);

            car.SharePrice(2);
            Assert.AreEqual(need, car.GetPrice());
        }
Beispiel #21
0
 public override void Visit(Prog n)
 {
     foreach (AST ast in n.prog)
     {
         ast.accept(this);
     }
     UnusedVariables();
 }
Beispiel #22
0
        public void CheckCarMethodIncrease()
        {
            double need = 10;
            Car    car  = new Prog(2);

            car.IncreasePrice(5);
            Assert.AreEqual(need, car.GetPrice());
        }
Beispiel #23
0
 public New_ProgVM(int id, SotrudnicWindowVM windowVM, Bank bank, Prog prog)
 {
     add           = false;
     ID            = id;
     this.windowVM = windowVM;
     this.bank     = bank;
     this.prog     = prog;
 }
Beispiel #24
0
        public void Part1(string input)
        {
            var p0 = new Prog(Parse(input).ToList(), new Dictionary <string, long>());

            p0.Run();

            Console.WriteLine("Result: " + p0.ResultPart1);
        }
Beispiel #25
0
 private void createShortcutSelectedProg()
 {
     if (progsListView.SelectedItems.Count == 1)
     {
         Prog prog = progList.Get(Int32.Parse(progsListView.SelectedItems[0].Name));
         ShortcutHelper.CreateShortcut(prog);
     }
 }
Beispiel #26
0
        public void CheckCarMethodSubstract()
        {
            double need = 0;
            Car    car  = new Prog(10);

            car.SubtractNumFromPrice(10);
            Assert.AreEqual(need, car.GetPrice());
        }
Beispiel #27
0
 public override void Visit(Prog n)
 {
     foreach (AST ast in n.prog)
     {
         ast.accept(this);
     }
     ;
     FunctionCheck();
 }
 public override void OnStartLocalPlayer()
 {
     base.OnStartLocalPlayer();
     if (isLocalPlayer)
     {
         this.GetComponent <Prog>().enabled = true;
         isLocalpl = this.GetComponent <Prog>();
     }
 }
Beispiel #29
0
 public override void VisitProgram(Prog n)
 {
     n.Settings.Visit(this);
     n.Deal.Visit(this);
     n.Collateral.Visit(this);
     n.Securities.Visit(this);
     n.CreditPaymentRules.Visit(this);
     n.Simulation.Visit(this);
 }
    public Node Prog()
    {
        var result = Exp();
        var node   = new Prog();

        node.Add(result);
        Expect(TokenCategory.EOF);
        return(node);
    }
Beispiel #31
0
        public static void Main()
        {
            try {
                Prog.hi ();
                JThrowable.CheckAndThrow ();
                Prog p = new ProgChild ();
                JThrowable.CheckAndThrow ();
                int r = 0;
                r = p.max (34, 15);
                JThrowable.CheckAndThrow ();
                Console.WriteLine ("Max is {0}", r);
                p.foo ();
                int[] arg = new int[2];
                arg[0] = 1;
                arg[1] = 2;
                r = p.foo9 (arg);
                Console.WriteLine ("foo9 is {0}", r);
                int[] array = p.fooC ();
                foreach (int i in array) {
                    Console.WriteLine ("fooC {0}", i);
                }
                p.fooA ();
                Prog[] p2 = new Prog[10];
                r = p.fooB (p2);
                Console.WriteLine ("fooB is {0}", r);

                //perf test
                for (int i = 0; i < 100000; i++)
                {
                    p.max (34, 15);
                }

                string s1 = "hello world";
                string s2 = new String(p.foo10(s1.ToCharArray()));
                Console.WriteLine ("Strings are equals: {0}", s1.Equals(s2));

                // throw an exception
                p.maxEx ();

            } catch (Exception e) {
                while (e != null) {
                    Console.WriteLine (e);
                    e = e.InnerException;
                }
            }
            Console.WriteLine ("Done!");
        }
Beispiel #32
0
 public virtual Prog[] fooA()
 {
     JObject o = _fooA.CallObject (this);
     JObjectArray array = new JObjectArray (o);
     JObject[] oArray = (JObject[]) array.Elements;
     int l = array.Length;
     Prog[] r = new Prog[l];
     for (int i = 0; i < l; i++) {
         r[i] = new Prog (oArray[i]);
     }
     return r;
 }
 public virtual void VisitProgram(Prog n)
 {
 }
Beispiel #34
0
 public virtual int fooB(Prog[] arg)
 {
     JObjectArray array = new JObjectArray (arg, Prog.JClass);
     return _fooB.CallInt (this, array);
 }