Finally back at looking through code...I am trying to eliminate the gotos in the sudoku function below:

I have eliminated simple gotos before...

Now, I am trying to eliminate the 4 goto statments without using breaks or continues...Code:double sum = 0.0; int x = 1; repeat: sum += 1.0 / x++; if (x <= N) goto repeat; printf("The sum of the first %d reciprocals is %lf\n", N, sum); Removal: double sum = 0.0; int x = 1; do { sum += 1.0 / x; x++; } while (x <= N); printf("The sum of the first %d reciprocals is %lf\n", N, sum);

Any ideas or suggestions on how to do this...flags, what?Code:bool sudoku_solver(int sudoku[][9], int& diff_single, int& diff_line, int& diff_row, int& diff_block) { bool empty_fields = true; bool operation_done; int counter; int empty_fields_counter; int sdk_to_solve [9][9]; diff_single = 0; diff_line = 0; diff_row = 0; diff_block = 0; int sudoku_bool[9][9][10]; for (int n = 0; n < 9; n++) { for (int m = 0; m < 9; m++) { for (int p = 0; p < 10; p++) { sudoku_bool[n][m][p] = true; } } } for (int m = 0; m < 9; m++) { for (int n = 0; n < 9; n++) { sdk_to_solve[m][n] = sudoku[m][n]; } } //main solver while (empty_fields) { operation_done = false; //Scanning for (int n = 0; n < 9; n++) { for (int m = 0; m < 9; m++) { if (sdk_to_solve[m][n] != NULL) { for (int i = 0; i < 10; i++) { sudoku_bool[m][n][i] = false; } for (int i = 0; i < 9; i++) { sudoku_bool[m][i][sdk_to_solve[m][n]] = false; sudoku_bool[i][n][sdk_to_solve[m][n]] = false; } for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { sudoku_bool[(3 * (m / 3)) + l][(3 * (n / 3)) + k][sdk_to_solve[m][n]] = false; } } } } } //analyze scanned pattern //single field defined value? for (int m = 0; m < 9; m++) { for (int n = 0; n < 9; n++) { int counter = 0; int last_true; for (int num = 1; num < 10; num++) { if (sudoku_bool[m][n][num]) { counter++; last_true = num; } } if (counter == 1) { sdk_to_solve[m][n] = last_true; operation_done = true; diff_single++; } } } if (operation_done) { goto field_counter; //eliminate me!!! } //Column defined field? for (int num = 1; num < 10; num++) { for (int m = 0; m < 9; m++) { int counter = 0; int last_field; for (int n = 0; n < 9; n++) { if (sudoku_bool[m][n][num]) { counter++; last_field = n; } } if (counter == 1) { sdk_to_solve[m][last_field] = num; operation_done = true; diff_line++; } } } if (operation_done) { goto field_counter; //eliminate me } //Row defined field? for (int num = 1; num < 10; num++) { for (int n = 0; n < 9; n++) { int counter = 0; int last_field; for (int m = 0; m < 9; m++) { if (sudoku_bool[m][n][num]) { counter++; last_field = m; } } if (counter == 1) { sdk_to_solve[last_field][n] = num; operation_done = true; diff_row++; } } } if (operation_done) { goto field_counter; //eliminate me } //block defined field? for (int num = 1; num < 10; num++) { for (int block_row = 0; block_row < 9; block_row += 3) { for (int block_line = 0; block_line < 9; block_line += 3) { counter = 0; int last_line; int last_row; for (int inblock_row = 0; inblock_row < 3; inblock_row++) { for (int inblock_line = 0; inblock_line < 3; inblock_line++) { if (sudoku_bool[block_row + inblock_row][block_line + inblock_line][num]) { counter++; last_row = block_row + inblock_row; last_line = block_line + inblock_line; } } } if (counter == 1) { sdk_to_solve[last_row][last_line] = num; operation_done = true; diff_block++; } } } } if (operation_done) { goto field_counter; //eliminate me } field_counter: empty_fields_counter = 0; for (int m = 0; m < 9; m++) { for (int n = 0; n < 9; n++) { if (sdk_to_solve[m][n] == NULL) { empty_fields_counter++; } } } if (empty_fields_counter == 0) { empty_fields = false; } if (empty_fields_counter != 0 && !operation_done) { return false; } } return true; }