Пример #1
0
        public static Complexity Check(DoubleLoopExercise exercise)
        {
            var column = GetColumn(exercise.OuterLoop);
            var row    = GetRow(exercise.InnerLoop);

            return(Answer[row, column]);
        }
Пример #2
0
        public void Single(
            [Values(VarType.N)] VarType outerBound,
            [Values(OpType.Increase)] OpType outerOp,
            [Values(VarType.Const)] VarType outerStep,
            [Values(VarType.N)] VarType innerBound,
            [Values(OpType.Multiply)] OpType innerOp,
            [Values(VarType.Prev)] VarType innerStep
            )
        {
            var random   = new Random(1224);
            var outer    = new Loop(outerBound, outerOp, outerStep);
            var inner    = new Loop(innerBound, innerOp, innerStep);
            var exercise = new DoubleLoopExercise(outer, LoopType.For, inner, LoopType.For);

            exercise.GetComplexity()
            .Should()
            .Be(ComplexityChecker.Check(exercise), exercise.GetCode(random));
        }