コード例 #1
0
            public DecimalClass Prosto()
            {
                int stack;

                if (up > down)
                {
                    stack = up;
                }
                else
                {
                    stack = down;
                }
                int i = 1;

                while (i < stack)
                {
                    if (up % i == 0 && down % i == 0)
                    {
                        up   /= i;
                        down /= i;
                        i     = 1;
                    }
                    i++;
                }
                DecimalClass newOne = new DecimalClass(up, down);

                return(newOne);
            }
コード例 #2
0
        public Node CorrectSort()
        {
            int  swapped;
            Node ptr1;
            Node lptr = null;


            if (head == null)
            {
                return(null);
            }

            do
            {
                swapped = 0;
                ptr1    = head;

                while (ptr1.Next != lptr)
                {
                    if (double.Parse(ptr1.Data.Decimal, CultureInfo.InvariantCulture) > double.Parse(ptr1.Next.Data.Decimal, CultureInfo.InvariantCulture))
                    {
                        DecimalClass t = ptr1.Data;
                        ptr1.Data      = ptr1.Next.Data;
                        ptr1.Next.Data = t;
                        swapped        = 1;
                    }
                    ptr1 = ptr1.Next;
                }
                lptr = ptr1;
            }while (swapped != 0);
            return(head);
        }
コード例 #3
0
        public void Add(DecimalClass data)
        {
            Node newNode = new Node(data);

            if (tail == null)
            {
                head = newNode;
            }
            else
            {
                newNode.Previous = tail;
                tail.Next        = newNode;
            }

            tail = newNode;
            Length++;
        }
コード例 #4
0
        public void ReadRow_AutoMappedDecimal_Success()
        {
            using var importer = Helpers.GetImporter("Doubles.xlsx");

            ExcelSheet sheet = importer.ReadSheet();

            sheet.ReadHeading();

            // Valid cell value.
            DecimalClass row1 = sheet.ReadRow <DecimalClass>();

            Assert.Equal(2.2345m, row1.Value);

            // Empty cell value.
            Assert.Throws <ExcelMappingException>(() => sheet.ReadRow <DecimalClass>());

            // Invalid cell value.
            Assert.Throws <ExcelMappingException>(() => sheet.ReadRow <DecimalClass>());
        }
コード例 #5
0
        public static void Decimal()
        {
            DecimalClass FirstOne = new DecimalClass();

            FirstOne.SetUp(15);
            FirstOne.SetDown(18);
            DecimalClass SecondOne = new DecimalClass();

            SecondOne.SetUp(2);
            SecondOne.SetDown(5);
            Console.WriteLine("Сложение 2ух дробных чисел = " + FirstOne.Summation(SecondOne).Prosto().GetUp() +
                              "/" + FirstOne.Summation(SecondOne).Prosto().GetDown() + "\n");
            Console.WriteLine("Вычитание 2ух дробных чисел = " + FirstOne.Subtraction(SecondOne).Prosto().GetUp() +
                              "/" + FirstOne.Subtraction(SecondOne).Prosto().GetDown() + "\n");
            Console.WriteLine("Перемножение 2ух дробных чисел = " + FirstOne.Мultiplication(SecondOne).Prosto().GetUp() +
                              "/" + FirstOne.Мultiplication(SecondOne).Prosto().GetDown() + "\n");
            Console.WriteLine("Деление 2ух дробных чисел = " + FirstOne.Division(SecondOne).Prosto().GetUp() +
                              "/" + FirstOne.Division(SecondOne).Prosto().GetDown() + "\n");
            Console.WriteLine("Вот это сейчас упростим: " + FirstOne.GetUp() + "/" + FirstOne.GetDown() + "\n");
            Console.WriteLine("Упрощаю: " + FirstOne.Prosto().GetUp() + "/" + FirstOne.Prosto().GetDown() + "\n");
        }
コード例 #6
0
        public void ReadRow_CustomMappedDecimal_Success()
        {
            using var importer = Helpers.GetImporter("Doubles.xlsx");
            importer.Configuration.RegisterClassMap <CustomDecimalClassMap>();

            ExcelSheet sheet = importer.ReadSheet();

            sheet.ReadHeading();

            // Valid cell value.
            DecimalClass row1 = sheet.ReadRow <DecimalClass>();

            Assert.Equal(2.2345m, row1.Value);

            // Empty cell value.
            DecimalClass row2 = sheet.ReadRow <DecimalClass>();

            Assert.Equal(-10, row2.Value);

            // Invalid cell value.
            DecimalClass row3 = sheet.ReadRow <DecimalClass>();

            Assert.Equal(10, row3.Value);
        }
コード例 #7
0
        public bool Remove(DecimalClass value)
        {
            Node current = head;

            while (current != null)
            {
                if (current.Data == value)
                {
                    if (current.Next == null)
                    {
                        tail = current.Previous;
                    }
                    else
                    {
                        current.Next.Previous = current.Previous;
                    }

                    if (current.Previous == null)
                    {
                        head = current.Next;
                    }
                    else
                    {
                        current.Previous.Next = current.Next;
                    }

                    current = null;
                    Length--;
                    return(true);
                }

                current = current.Next;
            }

            return(false);
        }
コード例 #8
0
ファイル: Node.cs プロジェクト: MattSpencerZA/DeweyDecimal
 public Node(DecimalClass data)
 {
     Data = data;
 }
コード例 #9
0
            public DecimalClass Division(DecimalClass other)
            {
                DecimalClass newOne = new DecimalClass(up * other.down, down * other.up);

                return(newOne);
            }
コード例 #10
0
            public DecimalClass Мultiplication(DecimalClass other)
            {
                DecimalClass newOne = new DecimalClass(up * other.up, down * other.down);

                return(newOne);
            }
コード例 #11
0
            public DecimalClass Subtraction(DecimalClass other)
            {
                DecimalClass newOne = new DecimalClass(up * other.down - other.up * down, down * other.down);

                return(newOne);
            }