示例#1
0
文件: MassTime.cs 项目: PakVl/OOP
        /// <summary>
        /// Время обработки ступеньчатого массива
        /// </summary>
        /// <returns></returns>
        public int TimedoSt()
        {
            doStairs = new Exam[n][];
            for (int i = 0; i < n; i++)
            {
                doStairs[i] = new Exam[n];
            }
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    doStairs[i][j] = new Exam("ds", i * j + 10000, new DateTime());
                }
            }
            int sum = 0;
            int start = Environment.TickCount;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    sum = (sum + doStairs[i][j].Mark * 3000000) ^ 31203;
                }
            }

            int stop = Environment.TickCount;
            return stop - start;
        }
示例#2
0
文件: MassTime.cs 项目: PakVl/OOP
        /// <summary>
        /// Время обработки одномерного массива
        /// </summary>
        /// <returns></returns>
        public int Timefirst()
        {
            int n2 = n * n;
            first = new Exam[n2];
            for (int i = 0; i < n2; i++)
            {
                first[i] = new Exam("f", i + 10000, new DateTime());
            }

            int sum = 0;
            int start = Environment.TickCount;

            for (int i = 0; i < n2; i++)
            {
                sum = (sum + first[i].Mark * 3000000) ^ 31203;
            }

            int stop = Environment.TickCount;
            int b = stop - start;
            return b;
        }
示例#3
0
文件: Student.cs 项目: PakVl/OOP
 public void AddExams(Exam[] NewList)
 {
     for (int i = 0; i < NewList.Length; i++)
     {
         ListExam.Add(NewList[i]);
     }
 }
示例#4
0
        static void Main(string[] args)
        {
            Student student = new Student();

            Console.WriteLine(student.ToShortString() + "\n");

            Console.WriteLine(student[Education.Master]);
            Console.WriteLine(student[Education.Bachelor]);
            Console.WriteLine(student[Education.SecondEducation] + "\n");

            student.Educat = Education.Bachelor;

            Person person = new Person("Ivan", "Koksov", new DateTime());

            student.Person = person;
            student.Number = 5;
            Console.WriteLine(student + "\n");

            Exam[] exam = new Exam[3];
            exam[0] = new Exam("c#", 5, new DateTime(2016, 9, 16));
            exam[1] = new Exam("java", 5, new DateTime(2016, 9, 16));
            exam[2] = new Exam("pyton", 5, new DateTime(2016, 9, 16));
            student.AddExams(exam);
            Console.WriteLine(student + "\n");

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            int n, m, i, j, nActual, nAll = 0, count = 0, time;

            Console.WriteLine("Enter n and m(('n','m') or ('n' 'm')).");

            string str = Console.ReadLine();

            string[] arr = str.Split(' ', ',');

            n = Int32.Parse(arr[0]);
            m = Int32.Parse(arr[1]);

            nActual = n * m;

            while (nAll < nActual)
            {
                nAll += ++count;
            }

            Console.WriteLine("n = " + n + ", m = " + m + ", count = " + count);

            Exam[] ex1 = new Exam[n * m];
            Exam[,] ex2 = new Exam[n, m];
            Exam[][] ex3 = new Exam[count][];
            Exam[][] ex4 = new Exam[n][];

            for (i = 0; i < ex3.Length - 1; i++)
            {
                ex3[i] = new Exam[i + 1];
            }

            ex3[i] = new Exam[nActual - nAll + count];

            for (i = 0; i < ex3.Length; i++)
            {
                for (j = 0; j < ex3[i].Length; j++)
                {
                    ex3[i][j] = new Exam();
                }
            }

            time = Environment.TickCount;

            for (i = 0; i < ex3.Length; i++)
            {
                for (j = 0; j < ex3[i].Length; j++)
                {
                    ex3[i][j].Name = "default";
                }
            }

            Console.WriteLine(Environment.TickCount - time);

            for (i = 0; i < n; i++)
            {
                ex4[i] = new Exam[m];
            }

            for (i = 0; i < ex4.Length; i++)
            {
                for (j = 0; j < ex4[i].Length; j++)
                {
                    ex4[i][j] = new Exam();
                }
            }

            time = Environment.TickCount;

            for (i = 0; i < ex4.Length; i++)
            {
                for (j = 0; j < ex4[i].Length; j++)
                {
                    ex4[i][j].Name = "default";
                }
            }

            Console.WriteLine(Environment.TickCount - time);

            for (i = 0; i < ex1.Length; i++)
            {
                ex1[i] = new Exam();
            }

            time = Environment.TickCount;

            for (i = 0; i < ex1.Length; i++)
            {
                ex1[i].Name = "default";
            }

            Console.WriteLine(Environment.TickCount - time);

            for (i = 0; i < n; i++)
            {
                for (j = 0; j < m; j++)
                {
                    ex2[i, j] = new Exam();
                }
            }

            time = Environment.TickCount;

            for (i = 0; i < n; i++)
            {
                for (j = 0; j < m; j++)
                {
                    ex2[i, j].Name = "default";
                }
            }

            Console.WriteLine(Environment.TickCount - time);

            //////////////////////////////////////////////////////
        }
示例#5
0
文件: MassTime.cs 项目: PakVl/OOP
        /// <summary>
        /// Время  обработки двумерного массива
        /// </summary>
        /// <returns></returns>
        public int TimeRec()
        {
            doRec = new Exam[n, n];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    doRec[i, j] = new Exam("dr", i * j + 10000, new DateTime());
                }
            }

            int sum = 0;
            int start = Environment.TickCount;

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    sum = (sum + doRec[i, j].Mark * 3000000) ^ 31203;
                }
            }

            int stop = Environment.TickCount;
            return stop - start;
        }
示例#6
0
        static void Main(string[] args)
        {
            Journal           journal1 = new Journal();
            Journal           journal2 = new Journal();
            StudentCollection coll1    = new StudentCollection();
            StudentCollection coll2    = new StudentCollection();

            Student[] st;
            Exam[]    exam;
            Test[]    test;

            coll1.StudentCountChanged     += journal1.OnStudentCountChanged;
            coll1.StudentReferenceChanged += journal1.OnStudentReferenceChanged;

            coll2.StudentCountChanged     += journal1.OnStudentCountChanged;
            coll2.StudentReferenceChanged += journal1.OnStudentReferenceChanged;

            coll1.StudentCountChanged     += journal2.OnStudentCountChanged;
            coll1.StudentReferenceChanged += journal2.OnStudentReferenceChanged;

            coll1.Name = "coll1";
            st         = new Student[3];

            st[0] = new Student(new Person("ivan", "ivan", new DateTime(33, 5, 5)), Education.Bachelor, 100);

            exam    = new Exam[2];
            exam[0] = new Exam("Java", 4, new DateTime());
            exam[1] = new Exam("C#", 4, new DateTime());

            test    = new Test[2];
            test[0] = new Test("Phyton", true);
            test[1] = new Test("Java", true);

            st[0].AddExam(exam);
            st[0].AddTest(test);

            st[1] = new Student(new Person("abc", "abc", new DateTime(4, 4, 4)), Education.Master, 100);

            exam    = new Exam[2];
            exam[0] = new Exam("Java", 2, new DateTime());
            exam[1] = new Exam("C#", 2, new DateTime());

            test    = new Test[2];
            test[0] = new Test("Phyton", true);
            test[1] = new Test("Java", true);

            st[1].AddExam(exam);
            st[1].AddTest(test);

            st[2] = new Student(new Person("wer", "wer", new DateTime(1, 1, 1)), Education.Bachelor, 100);

            exam    = new Exam[2];
            exam[0] = new Exam("Java", 3, new DateTime());
            exam[1] = new Exam("C#", 3, new DateTime());

            test    = new Test[2];
            test[0] = new Test("Phyton", true);
            test[1] = new Test("Java", true);

            st[2].AddExam(exam);
            st[2].AddTest(test);

            coll1.AddStudents(st);

            coll2.Name = "cool2";

            coll2.AddDefaults();

            coll1.Remove(1);

            coll1[1] = st[0];

            Console.WriteLine("\n\nFirst:\n\n" + journal1 + "\n\nSecond:\n\n" + journal2);
        }
示例#7
0
        static void Main(string[] args)
        {
            StudentCollection coll = new StudentCollection();
            int  n;
            bool f;

            Student [] st = new Student[3];

            st[0] = new Student(new Person("ivan", "ivan", new DateTime(33, 5, 5)), Education.Bachelor, 100);

            Exam[] exam = new Exam[2];
            exam[0] = new Exam("Java", 4, new DateTime());
            exam[1] = new Exam("C#", 4, new DateTime());

            Test[] test = new Test[2];
            test[0] = new Test("Phyton", true);
            test[1] = new Test("Java", true);

            st[0].AddExam(exam);
            st[0].AddTest(test);

            st[1] = new Student(new Person("abc", "abc", new DateTime(4, 4, 4)), Education.Master, 100);

            exam    = new Exam[2];
            exam[0] = new Exam("Java", 2, new DateTime());
            exam[1] = new Exam("C#", 2, new DateTime());

            test    = new Test[2];
            test[0] = new Test("Phyton", true);
            test[1] = new Test("Java", true);

            st[1].AddExam(exam);
            st[1].AddTest(test);

            st[2] = new Student(new Person("wer", "wer", new DateTime(1, 1, 1)), Education.Bachelor, 100);

            exam    = new Exam[2];
            exam[0] = new Exam("Java", 3, new DateTime());
            exam[1] = new Exam("C#", 3, new DateTime());

            test    = new Test[2];
            test[0] = new Test("Phyton", true);
            test[1] = new Test("Java", true);

            st[2].AddExam(exam);
            st[2].AddTest(test);

            coll.AddStudents(st);

            Console.WriteLine("\n" + coll.ToString());

            coll.SortListByAverage();

            Console.WriteLine("\n" + coll.ToString());

            coll.SortListBySecondName();

            Console.WriteLine("\n" + coll.ToString());

            coll.SortListByDate();

            Console.WriteLine("\n" + coll.ToString());

            Console.WriteLine("\n" + coll.Max + "\n");

            foreach (Student temp in coll.MasterStudent)
            {
                Console.WriteLine(temp);
            }

            Console.WriteLine("\n");

            foreach (Student temp in coll.AverageMarkGroup(3))
            {
                Console.WriteLine(temp);
            }

            Console.WriteLine("\n Enter n! \n");

            while (true)
            {
                f = int.TryParse(Console.ReadLine(), out n);
                if (f)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Not correct!");
                }
            }

            try
            {
                TestCollections t = new TestCollections(n);
                Console.WriteLine(t.Timer());
            }
            catch (Exception e) { Console.WriteLine(e.Message); }
        }