Skip to content

Commit

Permalink
Добавил пример кода для генерации случайных чисел без повтора
Browse files Browse the repository at this point in the history
  • Loading branch information
zloy-zhake committed Sep 8, 2016
1 parent a593b33 commit 2fcdc97
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions AnswerGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ void Generate_Answers()
// Qn,An,A-,A-,A-,A-;
//}
// A- выбираются случайным образом из всех A, кроме правильного.

// If you just want to generate a random number that never repeats you could do something like this

private Random rand = new Random();
private List<int> used = new List<int>;
protected int randomNonrepeating()
{
int i = rand.next();
while(used.contains(i)){
i = rand.next();
}
used.add(i);
return i;
}
}

}

void Save_Tests_To_File()
Expand Down

0 comments on commit 2fcdc97

Please sign in to comment.