public void ReadF(string fn) { String[] lines = System.IO.File.ReadAllLines(fn); int l = 0; foreach (string line in lines) { if (l != 0) { List <string> ele = new List <string>(line.Split(' ', StringSplitOptions.RemoveEmptyEntries)); if (ele.Count > 4) { string var = ele[0]; string pav = ele[1]; List <int> n = new List <int>(); for (int i = 2; i < ele.Count - 1; i++) { n.Add(Convert.ToInt32(ele[i])); } int eg = Convert.ToInt32(ele[ele.Count - 1]); Mokinys mok = new Mokinys(); mok.Enterdataman(var, pav, n, eg); mokiniai.Add(mok); mokiniaill.AddLast(mok); mokiniaiq.Enqueue(mok); } //Console.WriteLine("{0,0} {1,0} {2,0} {3, 0}",var, pav, string.Join("; ", n), eg); } l++; } }
public void DoFour(string fn, int n) { var watch = new System.Diagnostics.Stopwatch(); watch.Start(); //Console.WriteLine("įveskite kiek failų ruošiaties generuoti"); Console.WriteLine("generuojamas " + fn); string docPath = defdir; StreamWriter outputFile = new StreamWriter(Path.Combine(docPath, fn)); outputFile.WriteLine("Vardas Pavarde nd1 nd2 nd3 nd4 nd5 Egzaminas"); for (int j = 1; j <= n; j++) { string vardas = "Vardas" + Convert.ToString(j); string pavarde = "Pavarde" + Convert.ToString(j); int nd1 = random.Next(1, 10); int nd2 = random.Next(1, 10); int nd3 = random.Next(1, 10); int nd4 = random.Next(1, 10); int nd5 = random.Next(1, 10); int egz = random.Next(1, 10); string stud = vardas + " " + pavarde + " " + Convert.ToString(nd1) + " " + Convert.ToString(nd2) + " " + Convert.ToString(nd3) + " " + Convert.ToString(nd4) + " " + Convert.ToString(nd5) + " " + Convert.ToString(egz); outputFile.WriteLine(stud); List <int> nd = new List <int>(); nd.Add(nd1); nd.Add(nd2); nd.Add(nd3); nd.Add(nd4); nd.Add(nd5); Mokinys mok = new Mokinys(); mok.Enterdataman(vardas, pavarde, nd, egz); mokiniai.Add(mok); } mokiniai.Sort((s1, s2) => s1.galutinisvid.CompareTo(s2.galutinisvid)); outputFile.Close(); Console.WriteLine("Sukategoruojama į failus"); string kat2 = "galvociai.txt"; string kat1 = "vargsiukai.txt"; StreamWriter outkat2 = new StreamWriter(Path.Combine(defdir, kat2), true); StreamWriter outkat1 = new StreamWriter(Path.Combine(defdir, kat1), true); outkat2.WriteLine("{0,30}{1,20}{2,20}", "Vardas", "Pavarde", "Galutinis(vid)"); outkat1.WriteLine("{0,20}{1,20}{2,20}", "Vardas", "Pavarde", "Galutinis(vid)"); for (int k = 0; k < mokiniai.Count; k++) { mokiniai[k].PrintFileb(outkat1, outkat2); } outkat1.Close(); outkat2.Close(); watch.Stop(); Console.WriteLine($"Execution Time: {watch.ElapsedMilliseconds} ms"); }