Exemplo n.º 1
0
 public static ArrayList sortSelection(ArrayList list)
 {
     for (int i = 0; i < list.Size - 1; i++)
     {
         int min = i;
         for (int j = i + 1; j < list.Size; j++)
         {
             if (list.list[j].Average < list.list[min].Average)
             {
                 min = j;
             }
         }
         Student temp = list.list[i];
         list.list[i] = list.list[min];
         list.list[min] = temp;
     }
     return list;
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Student Vasya = new Student("Vasya", "Galeev");
            Student Marsel = new Student("Marsel", "Sidikov");
            Student Ranis = new Student("Ranis", "Nigmatullin");

            Vasya.fillMarks(99, 99, 99, 99);
            Vasya.calcAverage();
            Marsel.fillMarks(1, 2, 4, 7);
            Marsel.calcAverage();
            Marsel.print();
            Ranis.fillMarks(20, 50, 70, 50);
            Ranis.calcAverage();

            ArrayList list = new ArrayList();
            //ArrayList sortedList = new ArrayList();
            list.addStudent(Vasya);
            list.addStudent(Marsel);
            list.addStudent(Ranis);

            //sortedList = ArrayList.sortSelection(list);
            list.Swap(Vasya, Ranis);
            list.print();

            Console.ReadLine();
        }