- TS TS
- #41
Baka makakuha ka ng idea. Yan nalang maibibgay kong tulong sayo.
Code:
#include <iostream>
#include <stdlib.h> /* srand, rand */
#include <time.h>
using namespace std;
int main()
{
srand (time(NULL));
string easyQuestions[15] =
{
"Question 01",
"Question 02",
"Question 03",
"Question 04",
"Question 05",
"Question 06",
"Question 07",
"Question 08",
"Question 09",
"Question 10",
"Question 11",
"Question 12",
"Question 13",
"Question 14",
"Question 15",
};
int randomNumber;
int shownQuestion[5] = {-1, -1, -1, -1, -1};
bool shown = false;
int totalQuestion = 0;
while(totalQuestion < 5)
{
randomNumber = rand() % 15;
//Check if shown
for(int j = 0; j < 5; j++)
{
if(shownQuestion[j] == randomNumber)
{
shown = true;
break;
}
}
if(!shown)
{
//Show Question now
cout<< easyQuestions[randomNumber] << endl;
shownQuestion[totalQuestion] = randomNumber;
totalQuestion++;
}
shown = false;
}
return 0;
}