Hi, quick question. How do you output its location? Like row 1 column 2. It's a 5 x 5 grid, random numbers from 1 - 10, user asked for what number they're searching for and prints out how many times it appeared. Then print outs the location. Thanks for any inputs
1 2 3 4 5 6 7 8 9 10 11 12 13
int countNums(int ar[][5], int size, int search)
{
int count = 0;
for (int row = 0; row < 5; row++)
{
for (int col = 0; col < 5; col++)
{
if (ar[row][col] == search)
count++;
}
}
return count;
}
when looking for it..
cout << row << " "<<col; //+ fancy printing with words and end of lines and things.
here,
for (int col = 0; col < 5; col++)
{
if (ar[row][col] == search)
{
cout << row << " "<<col;
count++;
}
}