0

I'm trying to make program that generate random SUDOKU, but i'm new to C++, so i don't know how to use 2 Dimensions arrays in function to check is everything correct. could you help me please? squares are eapty, cause i need to rewrite it. i didn't understand the cherno multi-dimensions arrays

fullcode: https://pastebin.com/nc6Dagbh

stop=CheckEverything(*table, random,column,row);

bool CheckEverything(int *table,int random,int column,int row){
    if (CheckRows(*table, random,column,row) && CheckColumn(*table, random,column,row) && CheckSquares(*table, random,column,row))  // if everything is true
        return true;                                                                            // everything is true
    else                                                                                        // if not
        return false;                                                                           // it's not
}


bool CheckRows(int *table, int random,int column, int row){             // Check unique values in a row
    for (int counter = 0; counter < row; counter++) {
        if (random == table[counter][row])                              // if there were value like actually random number
            return false;                                               // find new value
        else                                                            // if there weren't
            return true;                                                // else it's correct                                                
    }
}
redve
  • 1
  • Side note: `if(X) return true; else return false;` can be rewritten as simply `return X;`. And your second function will always stop after first loop iteration, no matter how much `row` is. – Yksisarvinen Apr 28 '20 at 11:08
  • 3
    Use a `std::array, 9>` instead and everything becomes easier. You can pass it by reference and it'll retain the size information. – Ted Lyngmo Apr 28 '20 at 11:09

0 Answers0