Here is an example output:

Student 1 will grade: 4 3 2 5 <- CORRECT OUTPUT (no exam appears more than once)

Student 2 will grade: 5 5 5 1 <- exam 5 appears three times

Student 3 will grade: 4 2 2 2 <- exam 2 appears three times

Student 4 will grade: 3 3 1 1 <- exams 3 and 1 each appear twice

Student 5 will grade: 1 3 4 4 <- exam 4 appears twice

(each exam appears four times and every student is assigned four exams. no one gets their own)

Here is my code (area of problem is close to the bottom):

#include <stdio.h> #include <stdlib.h> #include <time.h> void create_class (int); int main (void) { srand(time(NULL)); // ASSIGN TOTAL NUMBER OF STUDENTS int students; printf ("Number of students: "); scanf ("%d", &students); // ASSIGN EXAM LIMIT int limit; printf ("Number of exams per student: "); scanf ("%d", &limit); // ASSIGN EXAM DISTRIBUTION int distribution; distribution = students / limit; printf ("distribution: %d\n\n", distribution); // ASSIGN NUMBERS TO EVERY STUDENT int i; int number; int class[students]; for (i = 0; i < students; i++) { printf ("Student %d Exam Number: ", i + 1); scanf ("%d", &number); class[i] = number; } // DECLARE COUNT ARRAY int count[students]; for (i = 0; i < students; i++) { count[i] = 0; } // DECLARE EXAMS ARRAY int exams[limit]; for (i = 0; i < limit; i++) { exams[i] = 0; } // ASSIGN EXAMS TO EVERY STUDENT int random; for (i = 0; i < students; i++) { printf ("\n\nStudent %d will grade: ", class[i]); int j; // THIS IS WHERE I NEED HELP GENERATING UNIQUE NUMBERS for (j = 0; j < limit; j++) { random = rand() % students; while (count[random] >= limit || class[random] == class[i]) { random = rand() % students; } count[random] += 1; printf ("%d ", class[random]); } } getch(); return 0; }

I tried keeping the exams for each student in the array exam and then checking each one every time I generate a number, but that didn't work. I've been spending hours trying to figure this out, so any help is greatly appreciated