示例#1
0
/**
	Chessboard array gets passed to here. For loop which loops through all solutions
	is found here
 */
void print_3D_array(int*** array, int no_3D_iterations, int no_2D_iterations, bool solutions_array, bool debug)
{
	string heading; // Heading to print each time the chessboard is printed. Depends on array type inputted into function

	// Check if array being passed is for solutions array or debug array

	if (solutions_array)
	{
		strcpy(heading.str, "SOLUTION NO "); // Method of assigning strings to char arrays in structs
	}
	else
	{
		strcpy(heading.str, "ATTEMPT NO ");
	}

	for(int i = 0; i < no_3D_iterations; i++)
	{
		// Print required heading
		printf("%s%i: \n", heading.str, i + 1);
		print_2D_array(array[i], no_2D_iterations, debug);

		// Print new line after chessboard has been printed
		printf("\n");
	}

}
示例#2
0
int main(int argc, char** argv) {

    /* or array[][2]*/
    int array[5][2] = {
        {2, 4},
        {6, 8},
        {10, 12},
        {14, 16},
        {18, 20}};
    int total_len = (sizeof (array) / sizeof (array[0][0]));
    int col_len = (sizeof (array) / sizeof (array[0]));
    int row_len = (sizeof (array[0]) / sizeof (array[0][0]));
    print_2D_array(array, col_len, row_len);

    return 0;
}