static void Main(string[] args) { int volba; Studenti studenti = new Studenti(); do { Console.WriteLine(@"MENU: 1)Nacti studenty z klavesnice 2)Vypis studentu 3)Serad podle cisla 4)Serad podle jmena 5)Serad podle fakulty "); volba = Cteni.NactiInt("Zadejte volbu z menu"); switch (volba) { case 1: studenti.Nacti(); break; case 2: studenti.Vypis(); break; case 3: //studenti.serad(delegate(Student a, Student b) //{ // return a.DejCislo() < b.DejCislo(); //}); studenti.Serad((a, b) => a.DejCislo() < b.DejCislo()); break; case 4: studenti.Serad(Student.MensiJmeno); break; case 5: //studenti.Serad(Student.MensiFakulta); MensiStudentCallback mensi = new MensiStudentCallback(Student.MensiFakulta); studenti.Serad(mensi); break; } } while (volba != 0); }
public void Serad(MensiStudentCallback mensiStudent) { bool vymena; for (int i = 0; i < pole.Length - 1; i++) { vymena = false; for (int j = 0; j < pole.Length - 1 - i; j++) { if (mensiStudent(pole[j + 1], pole[j])) { Student pom = pole[j + 1]; pole[j + 1] = pole[j]; pole[j] = pom; vymena = true; } } if (!vymena) return; } }
public void Serad(MensiStudentCallback mensiStudent) { bool vymena; for (int i = 0; i < pole.Length - 1; i++) { vymena = false; for (int j = 0; j < pole.Length - 1 - i; j++) { if (mensiStudent(pole[j + 1], pole[j])) { Student pom = pole[j + 1]; pole[j + 1] = pole[j]; pole[j] = pom; vymena = true; } } if (!vymena) { return; } } }