online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <cstdio> #include <cstdint> #include <cstring> int sol; int check(int turn, int * pl , int * hats) { int hatn = 0; if (hats[0] > 0) hatn++; if (hats[1] > 0) hatn++; if (hats[2] > 0) hatn++; switch (turn) { case 2: if ((pl[0] == pl[1]) && (pl[0] == pl[2])) {return 0;} if (hatn == 1) {return 0;} break; case 3: if ((pl[0] == pl[1]) && (pl[0] == pl[3])) {return 0;} if (hatn == 1) {return 0;} break; case 4: if ((pl[0] == pl[1]) && (pl[0] == pl[4])) {return 0;} if (hatn == 1) {return 0;} break; case 5: if (!((hatn == 1) || ((pl[0] == pl[1]) && (pl[0] == pl[5])))) {return 0;} break; case 6: if ((pl[0] == pl[1]) && (pl[0] == pl[6])) {return 0;} if (hatn == 1) {return 0;} break; case 7: if (!(hatn == 1)) {return 0;} break; default: break; } return 1; } void f(int turn, int * pla, int * hats) { if (turn == 9) { sol++; for(int b=0; b<9; ++b) { printf("%d", pla[b]); } printf("\n"); return; } for (int col = 0; col < 3; col++) { if (hats[col]) { pla[turn] = col; if (check(turn, pla, hats) == 1) { hats[col]--; f(turn +1, pla, hats); hats[col]++; } pla[turn] = -1; if (hats[col] == 3) { break; } } } } int main() { int hats[3] = {3, 3, 3}; int pl[10]; setbuf(stdout, NULL); for(int b=0; b<10; ++b) pl[b] = -1; sol = 0; f(0, pl, hats); fflush( stdout ); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue