unique int for every struct
Closed this issue · 3 comments
Tommac1 commented
Requirement was, that for every int field, it's value must be unique .
Consider adding the following code to make it done
do { structs[i]->i = (rand() % 10001) - 1000; present = 0; for (j = 0; (j < i) && (present == 0); ++j) { if (structs[j]->i == structs[i]->i) { present = 1; } } } while (present == 1);
EDIT
Please describe issue mode in detail when submitting ~VanDavv
VanDavv commented
I'm not really convinced to for loop nested in do-while loop.
I'd rather another array containing already taken int's and checking if picked int is not in that array
Tommac1 commented
do w/e you want