Hello,
I am writing a program which assigns hypothetically to each student (an actual program I have created) and make sure each student receives an unique question assign from 50 questions to 10 students to have 5 questions each. However, the program assigns some students are being assign the same question and others receive the same question twice. Here is my program:
Code:
#include<iostream>
using std::cout;
using std::ios;
#include<iomanip>
using std::setw;
using std::setprecision;
using std::setiosflags;
#include<algorithm>
#include<cstdlib>
#include<ctime>
int main()
{
srand( time( 0 ) );
int a[10][5], i , j;
cout << setw(8);
for( i = 1; i <=10; i++)
{
for( j = 1; j <=5; j++)
{
random_shuffle (a[i][j] = 1 + rand() % (50 - 1));
cout << a[i][j] << setw(8);
}
cout << '\n';
}
return 0;
}
I want to use either
Code:
random_shuffle or swap
so I can do my program but I am not sure if I putted in the right place.
Please help me fix my problem.
Thank you for some one who can guide me to solve the mistake I made.