Skip to main content
eick-at moodle
  • Home
  • Calendar
  • More
You are currently using guest access
Log in
eick-at moodle
Home Calendar
Expand all Collapse all
  1. Grundlagen OOP mit C#
  2. Prüfungsvorbereitung
  3. Aufgabe: Sortieralgorithmus

Aufgabe: Sortieralgorithmus

Completion requirements
Opened: Thursday, 22 June 2023, 12:00 AM
Due: Thursday, 29 June 2023, 12:00 AM

Ergänzen Sie das folgende Programm zur Übung um einen eigenen Sortieralgorithmus.

Wahlweise können Sie auch einen fertigen Sortieralgorithmus implementieren (z.B. Bubblesort). Wichtig ist nur, dass Sie einen Sortieralgorithmus für die Abschlussprüfung auswendig abrufen können.

  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         RandomArray ra = new RandomArray();
  6.         ra.print();
  7.         ra.mySort();
  8.         ra.print();
  9.         Console.ReadKey();
  10.     }
  11. }
  12.  
  13. class RandomArray
  14. {
  15.     private static int lenArray = 10;
  16.     private int[] array = new int[lenArray];                         // 1-dim. Array vom Typ int
  17.  
  18.     public RandomArray()
  19.     {
  20.         Random random = new Random();                                // Array mitz Zufallszahlen füllen
  21.         for (int i = 0; i < lenArray; i++)
  22.             array[i] = random.Next(100);          
  23.     }
  24.  
  25.     public void print()
  26.     {
  27.         for (int i = 0; i < lenArray; i++)                           // Array ausgeben
  28.             Console.WriteLine(array[i]);
  29.         Console.WriteLine("Fertig");
  30.     }
  31.  
  32.     public void mySort()
  33.     {
  34.         // to do
  35.     }
  36. }

You are currently using guest access (Log in)
Data retention summary
Get the mobile app
Powered by Moodle