1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
|
for (int i = 0; i < array.Length; i++) {
bool placed = false;
while (!placed) { // wiederhole sooft mit neuer Zufallszahl, bis es klappt
int help = r.Next(0, 5);
bool found = false;
for (int j = 0; j < i; j++) {
if (array[j] == help) found = true;
}
if (!found) { // kein doppelter Eintrag
placed = true;
array[i] = help;
}
}
} |