invalid operands in number generation
Sep 9, 2016 at 1:30pm UTC
hi to all,
ive got an invalid operands at line 38 when running this code.
i hope somebody will help me for this...
ive added an excempt array to be avoided in number generations,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
void gen(int num[]) {
for (int x=0; x<10;x=x+1) {
num[x] = x+1;
}
random_shuffle(&num[0], &num[10]);
int x;
for (x = 0; x<6; x++) { // selection of six numbers
}
}
void gendisp(int num[]) {
for (int x=0; x<10;x=x+1) {
num[x] = x+1;
}
random_shuffle(&num[0], &num[10]);
int x;
for (x = 0; x<6; x++) {
cout <<num[x] << " " ;
}
}
int main()
{
const int rows = 2;
const int cols = 6;
int excempt[rows][cols] = {{2,4,6,5,1,3},//how to avoid this set of numbers
{1,3,5,7,2,4}};
int numbers[10];
for (int i = 0; i < 10; ++i) {
cout << endl;
gen(numbers);
if (excempt == gen(numbers))
return 0;
else
gendisp(numbers);
}
return 0;
}
// error has occured...
// invalid operands of types ‘int [2][6]’ and ‘void’ to binary ‘operator==’
Sep 9, 2016 at 3:18pm UTC
gen
doesn't return anything. It's return is
void
, so you can't make an comparison with it like that.
Maybe try something like
1 2
if (checkForExcluded(excempt, numbers))
...
checkForExcluded
can return
true
if it finds the set you don't want, and return
false
otherwise.
If you call
gen
again with
numbers
as a parameter, you'll generate a new set of numbers for it. I'm guessing that's not what you want to do.
Sep 10, 2016 at 3:23am UTC
its just like lottery... i want to compare old results to new generated sets to be excluded when new sets is being generated... but ive still not made it...
Topic archived. No new replies allowed.