So i have printed out a 9X9 2D array filled with random integers.
my next step is check if numbers that are provided from an input file are in my 2D array. The numbers can only be valid/true if they are right next to each other in my array.
for example
154259
123437 in this example the number 1243, 5934 are valid numbers
764585 also i cannot reuse any number twice on my 2d array
345312
int main(){
srand(time(NULL));
char array2D[9][9];
for (int row = 0; row<10 ; row++){
for (int col = 0; col<10 ; col++){
array2D[row][col]= rand()%9+'1';
cout<< array2D[row][col] << " ";
}
cout << endl;
}
findNumb(); // im having issues using calling this function as well
return 0;
}
int findNumb(int row, int col, int a[][9]){
string line;
ifstream myfile ("number.txt");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
cout << line << '\n';
}
for (int i = 0; i < line.length(); i++)
{
if(line[i] == a[0][0]) // not sure how to search through the array
....
// this is where im getting stuck
}
else
}
return 0;
}
i have to use a recursive algorithm to solve this. And print out the coordinates for each number that i found. Please some help!
sorry you are right, silly error, corrected that,
also i know its not implemented, but when i had it do something simple like just cout the lines of numbers, it would give me an error, not sure if i called on it correctly.