Пример #1
0
        //TODO: Doesn't work, idk why

        /*public static void fill(Ecuation ecObj, int size) {
         *  CompoundNumber[,] ecuation = new CompoundNumber[size, size + 1];
         *  CompoundNumber[] unkowns = new CompoundNumber[size];
         *
         *  //populate unknowns
         *  for (int i = 0; i < unkowns.Length; i++)
         *      unkowns[i] = generateRandomCompound();
         *
         *  //populate with constants
         *  for (int i = 0; i < size; i++)
         *      for (int j = 0; j < size; j++)
         *          ecuation[i, j] = generateRandomCompound();
         *
         *  //find the results
         *  for (int i = 0; i < size; i++) {
         *
         *      CompoundNumber tmp = ecuation[i, 0] * unkowns[0];
         *      for (int j = 1; j < size; j++)
         *          tmp = tmp + (ecuation[i, j] * unkowns[j]);
         *
         *      ecuation[i, size] = tmp;
         *  }
         *
         *  ecObj.setEcuation(ecuation);
         * }*/

        private static void hardcoded(Ecuation ecObj)
        {
            CompoundNumber[,] matrix = new CompoundNumber[3, 4] {
                { new CompoundNumber(-1), new CompoundNumber(2), new CompoundNumber(0), new CompoundNumber(1) },
                { new CompoundNumber(1), new CompoundNumber(1), new CompoundNumber(1), new CompoundNumber(2) },
                { new CompoundNumber(1), new CompoundNumber(-1), new CompoundNumber(-1), new CompoundNumber(0) }
            };

            ecObj.setEcuation(matrix);
        }
Пример #2
0
        public static void fill(Ecuation ecObj)
        {
            Console.WriteLine("Introduceti numarul de necunoscute.");

            int size = Int32.Parse(Console.ReadLine());

            //Read constants
            CompoundNumber[,] ecuation = new CompoundNumber[size, size + 1];
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size + 1; j++)
                {
                    if (j != size)
                    {
                        Console.Write("Numarator pentru [{0}, {1}] = ", i, j);
                    }
                    else
                    {
                        Console.Write("Numaratorul rezultatului pentru linia {0} = ", i);
                    }
                    int numerator = Int32.Parse(Console.ReadLine());

                    if (j != size)
                    {
                        Console.Write("Numitorul pentru [{0}, {1}] = ", i, j);
                    }
                    else
                    {
                        Console.Write("Numitorul rezultatului pentru linia {0} = ", i);
                    }
                    int denominator = Int32.Parse(Console.ReadLine());

                    ecuation[i, j] = new CompoundNumber(numerator, denominator);
                    Console.WriteLine();
                }
            }
            ecObj.setEcuation(ecuation);
        }
Пример #3
0
        static void Main(string[] args)
        {
            //Lab1
            //int[] input = readInput(true);

            //SortingAlgorythm bubbleSort = new BubbleSort(input);
            //bubbleSort.sort();
            //bubbleSort.animate();

            //SortingAlgorythm selectSort = new SelectSort2(input);
            //selectSort.sort();
            //selectSort.animate();

            //SortingAlgorythm combSort = new CombSort(input);
            //combSort.sort();
            //combSort.animate();

            //Lab2
            //Ecuation ec = new Ecuation(3, 3);
            //double some = 3256532.6d;
            //Console.WriteLine(some.ToString());


            //Lab3
            //StudentNote studentNote = new StudentNote(false);
            //int student = 1;
            //int subj = 1;
            //Console.WriteLine("Media pentru studentul {0} la obiectul {1} este {2}",
            //    studentNote.getStudents()[student],
            //    studentNote.getSubjects()[subj],
            //    studentNote.mediaPentruStudentLaObiect(student, subj));

            CompoundNumber[,] matrix4 = new CompoundNumber[4, 5] {
                { new CompoundNumber(-1), new CompoundNumber(-2), new CompoundNumber(0), new CompoundNumber(3), new CompoundNumber(-6) },
                { new CompoundNumber(2), new CompoundNumber(3), new CompoundNumber(4), new CompoundNumber(4), new CompoundNumber(22) },
                { new CompoundNumber(2), new CompoundNumber(2), new CompoundNumber(3), new CompoundNumber(5), new CompoundNumber(20) },
                { new CompoundNumber(3), new CompoundNumber(1), new CompoundNumber(-5), new CompoundNumber(7), new CompoundNumber(-34) }
            };
            CompoundNumber[,] matrix3 = new CompoundNumber[3, 4] {
                { new CompoundNumber(-1), new CompoundNumber(2), new CompoundNumber(0), new CompoundNumber(6) },
                { new CompoundNumber(2), new CompoundNumber(3), new CompoundNumber(4), new CompoundNumber(40) },
                { new CompoundNumber(2), new CompoundNumber(2), new CompoundNumber(3), new CompoundNumber(30) }
            };

            //TODO: Investigate determinant calculation for 3+ levels

            Ecuation ecuation = new Ecuation();

            ecuation.setEcuation(matrix4);
            //ecuation.solve();
            //ecuation.prettyPrint();
            Console.WriteLine(new Determinant(
                                  new int[4, 4] {
                { 1, 2, 3, -2 },
                { -1, 0, 5, 1 },
                { 4, 1, -1, 3 },
                { 3, 2, 1, 4 }
            }

                                  /*new int[4, 4] {
                                   * { 1, 0, 0, 0},
                                   * { -1, 2, 8, -1},
                                   * { -4, -7, -13, 11},
                                   * { 3, -4, -8, 10}
                                   * }*/

                                  ).getValue());//should be 264

            Console.Read();
        }