예제 #1
0
        public void stundentai()
        {
            Boolean stop = false;

            while (stop != true)
            {
                var student = new Student();
                Console.WriteLine("Iveskite studento varda, pavarde ");
                var ivedimas = Console.ReadLine();
                var vardas   = ivedimas.Split(" ")?[0];
                var pavarde  = ivedimas.Split(" ")?[1];
                student.Vardas  = vardas;
                student.Pavarde = pavarde;
                Console.WriteLine("Jei norite sugeneruoti atsitiktinius pazymius iveskite (Y/N)");
                var generuoti = Console.ReadLine();
                if (generuoti.ToUpper() == "Y")
                {
                    Random rnd = new Random();
                    for (int i = 0; i < 3; i++)
                    {
                        student.Nd.Add(rnd.Next(1, 11));
                    }
                    student.Egz = rnd.Next(1, 11);
                }
                else
                {
                    Console.WriteLine("Jei zinote atliktu namu darbu skaiciu iveskite (Y/N)");
                    var nezinomi = Console.ReadLine();
                    if (nezinomi.ToUpper() == "Y")
                    {
                        Console.WriteLine("Iveskite atliktu namu darbu skaiciu");
                        var n = Console.ReadLine();
                        for (int i = 0; i < int.Parse(n); i++)
                        {
                            Console.WriteLine("Iveskite namu darbu rezultatus");
                            var nd = Console.ReadLine();
                            student.Nd.Add(double.Parse(nd));
                        }
                    }
                    if (nezinomi.ToUpper() == "N")
                    {
                        List <double> nzn = new List <double>();
                        Console.WriteLine("Iveskite namu darbu rezultatus baigus ivedima iveskite 'STOP'");
                        bool no = false;
                        while (no != true)
                        {
                            var pazymiai = Console.ReadLine();
                            if (pazymiai.ToUpper() == "STOP")
                            {
                                no = true;
                            }
                            else
                            {
                                student.Nd.Add(double.Parse(pazymiai));
                            }
                        }
                    }

                    Console.WriteLine("Iveskite egzamino rezultata ");
                    var egz = Console.ReadLine();
                    student.Egz = int.Parse(egz);
                }
                Students.Add(student);

                Console.WriteLine("testi studentu ivedima? (Y/N)");
                var tb = Console.ReadLine();
                if (tb.ToUpper() == "Y")
                {
                }
                else
                {
                    stop = true;
                }
            }
            galutinis();
        }
예제 #2
0
        public void studentaigenerate()
        {
            for (int i = 1; i <= 10000000; i++)
            {
                var    student = new Student();
                Random rnd     = new Random();
                var    vardas  = "Vardas" + i.ToString();
                var    pavarde = "Pavarde" + i.ToString();
                var    egz     = rnd.Next(1, 11);
                student.Vardas  = vardas;
                student.Pavarde = pavarde;
                student.Egz     = egz;
                for (int j = 1; j <= 6; j++)
                {
                    student.Nd.Add(rnd.Next(1, 11));
                }
                Students.Add(student);
            }
            galutinis();
            Stopwatch sw = new Stopwatch();

            string strPath = Environment.GetFolderPath(
                System.Environment.SpecialFolder.DesktopDirectory);
            string pathString = System.IO.Path.Combine(strPath, "Studentai");

            System.IO.Directory.CreateDirectory(pathString);
            for (int i = 1; i <= 5; i++)
            {
                using (System.IO.StreamWriter file =
                           new System.IO.StreamWriter(pathString + @"\Studentai" + i.ToString() + ".txt"))
                {
                    if (i == 1)
                    {
                        sw.Start();
                        file.WriteLine("{0, -20} {1, -20} {2, 20} {3,20} {4, 20} {5,20} {6, 20} {7,20} {8, 20}", "Vardas", "Pavarde", "ND1", "ND2", "ND3", "ND4", "ND5", "ND6", "Egz.\n");
                        for (int j = 0; j < 1000; j++)
                        {
                            file.WriteLine("{0, -20} {1, -20} {2, 20} {3,20} {4, 20} {5,20} {6, 20} {7,20} {8, 20}", Students[j].Vardas, Students[j].Pavarde, Students[j].Nd[0], Students[j].Nd[1], Students[j].Nd[2], Students[j].Nd[3], Students[j].Nd[4], Students[j].Nd[5], Students[j].Egz);
                        }
                        sw.Stop();
                        Console.WriteLine("Time Taken-->{0} ms", sw.ElapsedMilliseconds);
                    }
                    if (i == 2)
                    {
                        sw.Start();
                        file.WriteLine("{0, -20} {1, -20} {2, 20} {3,20} {4, 20} {5,20} {6, 20} {7,20} {8, 20}", "Vardas", "Pavarde", "ND1", "ND2", "ND3", "ND4", "ND5", "ND6", "Egz.\n");
                        for (int j = 0; j < 10000; j++)
                        {
                            file.WriteLine("{0, -20} {1, -20} {2, 20} {3,20} {4, 20} {5,20} {6, 20} {7,20} {8, 20}", Students[j].Vardas, Students[j].Pavarde, Students[j].Nd[0], Students[j].Nd[1], Students[j].Nd[2], Students[j].Nd[3], Students[j].Nd[4], Students[j].Nd[5], Students[j].Egz);
                        }
                        sw.Stop();
                        Console.WriteLine("Time Taken-->{0} ms", sw.ElapsedMilliseconds);
                    }
                    if (i == 3)
                    {
                        sw.Start();
                        file.WriteLine("{0, -20} {1, -20} {2, 20} {3,20} {4, 20} {5,20} {6, 20} {7,20} {8, 20}", "Vardas", "Pavarde", "ND1", "ND2", "ND3", "ND4", "ND5", "ND6", "Egz.\n");
                        for (int j = 0; j < 100000; j++)
                        {
                            file.WriteLine("{0, -20} {1, -20} {2, 20} {3,20} {4, 20} {5,20} {6, 20} {7,20} {8, 20}", Students[j].Vardas, Students[j].Pavarde, Students[j].Nd[0], Students[j].Nd[1], Students[j].Nd[2], Students[j].Nd[3], Students[j].Nd[4], Students[j].Nd[5], Students[j].Egz);
                        }
                        sw.Stop();
                        Console.WriteLine("Time Taken-->{0} ms", sw.ElapsedMilliseconds);
                    }
                    if (i == 4)
                    {
                        sw.Start();
                        file.WriteLine("{0, -20} {1, -20} {2, 20} {3,20} {4, 20} {5,20} {6, 20} {7,20} {8, 20}", "Vardas", "Pavarde", "ND1", "ND2", "ND3", "ND4", "ND5", "ND6", "Egz.\n");
                        for (int j = 0; j < 1000000; j++)
                        {
                            file.WriteLine("{0, -20} {1, -20} {2, 20} {3,20} {4, 20} {5,20} {6, 20} {7,20} {8, 20}", Students[j].Vardas, Students[j].Pavarde, Students[j].Nd[0], Students[j].Nd[1], Students[j].Nd[2], Students[j].Nd[3], Students[j].Nd[4], Students[j].Nd[5], Students[j].Egz);
                        }
                        sw.Stop();
                        Console.WriteLine("Time Taken-->{0} ms", sw.ElapsedMilliseconds);
                    }
                    if (i == 5)
                    {
                        sw.Start();
                        file.WriteLine("{0, -20} {1, -20} {2, 20} {3,20} {4, 20} {5,20} {6, 20} {7,20} {8, 20}", "Vardas", "Pavarde", "ND1", "ND2", "ND3", "ND4", "ND5", "ND6", "Egz.\n");
                        for (int j = 0; j < 10000000; j++)
                        {
                            file.WriteLine("{0, -20} {1, -20} {2, 20} {3,20} {4, 20} {5,20} {6, 20} {7,20} {8, 20}", Students[j].Vardas, Students[j].Pavarde, Students[j].Nd[0], Students[j].Nd[1], Students[j].Nd[2], Students[j].Nd[3], Students[j].Nd[4], Students[j].Nd[5], Students[j].Egz);
                        }
                        sw.Stop();
                        Console.WriteLine("Time Taken-->{0} ms", sw.ElapsedMilliseconds);
                    }
                }
            }
        }