samedi 31 décembre 2016

Random int with no repeat in c++

I am making a quiz application. All the questions are strored in table and every question means one row. Every row is an int variable. Program prints 3 random questions from 5 stored questions with this code:

i = rand() % 5 + 1;

i means a row in table, so it randomly chooses one row and question and print it. It all i labeled as "QUESTION" and in the end there is a code:

goto QUESTION;

Which makes the program choose the question once again. What code should I implement more to make the program NOT TO choose questions already choosen?




Aucun commentaire:

Enregistrer un commentaire