match the brackets, notice that you are closing the function on line 11 without returning any value.

0

match the brackets, notice that you are closing the function on line 11 without returning any value.

0

ya i looked at my curly braces and fixed them amazingly it works, now how do i go about getting more than 1 col? in the main func can i change the values of my ranges for each? or how can I proceed?

0

From looking at your code I still have a hard time understanding what you want to do, please write a **VERY** clear step by step algorithm in pseudo-code for that part that way I can be of help.

I will see what I can do with that.

0

int cardNums(int nums[5][5])

int cardNumsArray[5][5]

for (int a=0;a<5;a++)

for(int b=0;b<5;b++)

cardNumsArray[a]**=a x b
print cardNumsArray**

now for each col (5 in total) there is a specified range to get random numbers I used this. This is also where I get confused, b/c another array is needed to sort those numbers to make sure they don't repeat. I want to call this checking array another function, would this be allowed?

0

That doesn't help me understand what you want to do at all if you just tell me you are confused about it.

Please explain thoroughly and specifically how you want random numbers to be generated, and where to stick em, and there aren't just 5 columns, there are 5 columns for each row, if you can, think about a STEP by STEP algorithm you want to use to accomplish your goal, and then post that here so that I can help you.

Also a trick I use to make sure random numbers don't repeat sometimes is to populate a vector with numbers with the range I want, suppose I have this:

```
vector<int> vec;
for (int i = 1; i <= 100; i++)
vec.push_back(i);
```

that will populate a vector with 100 elements ranging from 1 to 100.

Then suppose I want to populate a vector with numbers 1-100 in random order with no repeats.

```
vector<int> randvec;
while (vec.size() > 0)
{
randnum = rand()%vec.size(); // generate rand num in index range of vec to steal from
randvec.push_back(vec[randnum]); // copy from that index
vec.erase(vec.begin() + i); //remove from vec of 1-100 the random num used
//this way the next time randnum = rand()%vec.size(); is
//used, it doesn't have a chance of repeating a number
}
```

*Edited
by mike_2000_17*: Fixed formatting

0

ok ill start with my 2d array,

```
int cardNums(int nums[][5]) //this is a func for an array, where the values of var a, b are going to change
{
int cardNumsArray[5][5];
for(int a=0; a < 5; a++)
{ for(int b=0; b < 5; b++)
cardNumsArray[a][b] = a * b;//
}
return 0;
```

int main()

{

cout<<cardNums<<endl;

return 0;

}

0

took me awhile but here it is

make 2d array<-int cardNumsArray[5][5]

populate this array with this function <-int noRepeats(int arrayCk[5][5])

int checkArray[5][5]

srand((unsigned)time(0));

int random_integer;

int lowest=1, highest=15;

int range=(highest-lowest)+1;

for(int index=0; index <5;)

random_integer = lowest+rand()/(RAND_MAX/(highest-lowest) + 1);

if(checkArray[random_integer-1])

checkArray[random_integer-1];

cout << random_integer << endl;

index++;

for (random_integer=0;random_integer<5;random_int++)

for (random_integer=0;random_integer<5;random_integer++)

print random_integer in cardNumsArray

this is what I hav, hopefully u can understand it

thx

0

took me awhile but here it is

make 2d array<-int cardNumsArray[5][5]

populate this array with this function <-int noRepeats(int arrayCk[5][5])

int checkArray[5][5]

srand((unsigned)time(0));

int random_integer;

int lowest=1, highest=15;

int range=(highest-lowest)+1;

for(int index=0; index <5;)

random_integer = lowest+rand()/(RAND_MAX/(highest-lowest) + 1);

if(checkArray[random_integer-1])checkArray[random_integer-1];

cout << random_integer << endl;

index++;

for (random_integer=0;random_integer<5;random_int++)

for (random_integer=0;random_integer<5;random_integer++)

print random_integer in cardNumsArraythis is what I hav, hopefully u can understand it

thx

I think we need to see the full program, and with code tags and formatting/indentation please. It makes it MUCH easier to debug for both us and you. Thanks.

0

```
#include <iostream>
//put additional include lines here as needed
//include <packageName>
using namespace std;
int cardNums(int nums[5][5], int x, int y) //this is a func for an array, where the values of var a, b are going to change
{
int cardNumsArray[5][5];
for(int a=0; a < 5; a++)
{ for(int b=0; b < 5; b++)
cardNumsArray[a][b] = a * b;//
cout<<cardNumsArray[5]<<endl;
}
return 0;
}
int noRepeats(int arrayCk[5][5])
{
int checkArray[5][5];
srand((unsigned)time(0));
int random_integer;//for 1 col
int lowest=1, highest=15;//these var values change
int range=(highest-lowest)+1;//the range changes in each col
for(int index=0; index <5;)//
{
random_integer = lowest+rand()/(RAND_MAX/(highest-lowest) + 1);
if(checkArray[random_integer-1])
{
checkArray[random_integer-1];
cout << random_integer << endl;
index++;
}
}
return 0;
}
int main()
{
char bingoCard[5];
bingoCard[0]='B';
bingoCard[1]='I';
bingoCard[2]='N';
bingoCard[3]='G';
bingoCard[4]='O';
cout <<"| B " << "| I " << "| N " << "| G |" << " O | " << endl;
int cardNumsArray [5][5];
cardNums(cardNumsArray,5,5);
cout<<cardNums<<endl;
return 0;
}
```

0

Lines 13 - 18:

```
for(int a=0; a < 5; a++)
{ for(int b=0; b < 5; b++)
cardNumsArray[a][b] = a * b;//
cout<<cardNumsArray[5]<<endl;
}
```

This fills in the array perfectly fine, but line 16 is an error.

`cout<<cardNumsArray[5]<<endl;`

I'm not sure if this line is supposed to be part of the inner for-loop controlled by the variable b or not, but currently it is not. If you want it to be part of that inner loop, you need to add some brackets. Also cardNumsArray is a 2-dimensionional array and you are only using one index: 5. You need two indexes.

Same problem in lines 36 and 38. checkArray is a 2-dimensional array and you only have one index for it in those lines. Line 64 doesn't make any sense. You are trying to output a function. Are you trying to call that function? If so, it needs to have some parameters. You called it in line 63, but you are not calling it in line 64.

This topic has been dead for over six months. Start a new discussion instead.

Recommended Topics

`data = binary_file.read()`

is to read the whole ...