Hello, Everyone:
Today, I am trying to program in C++ which helps me assign hypothetically to each students from 50 questions. Unfortunately, when I wrote the program I am getting that some students have the same question number assign as other students and a few have the same question assign twice. Can you help me figure out what I did wrong in my program and how can I fix the program so each student has a unique question.
Here is the program:
I will appreciate any help from some one.Code:#include<iostream> using std::cout; using std::ios; #include<iomanip> using std::setw; using std::setprecision; using std::setiosflags; #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++) { a[i][j] = 1 + rand() % 50; cout << a[i][j] << setw(8); } cout << '\n'; } return 0; } <pegasus> g++ duplicates.cpp <pegasus> a.out 35 13 26 39 25 30 5 37 22 5 18 33 21 15 47 42 37 34 18 43 3 42 45 16 1 10 6 29 22 24 31 39 13 9 8 6 5 6 3 48 24 15 17 23 4 40 36 20 26 10 <pegasus>
Sincerely,
Mike



LinkBack URL
About LinkBacks


