/* ------------------------------------------------------------------------- */ int main(int argc, char *argv[]) { board_t board; board_t board_in; board_t board_solved; // XXX - someday download and use argtable project // XXX - no, actually use getopt procCmdLine(argc, argv); // Open the output file openFiles(); // OK LET'S GO ... initBoard(&board); // read in the starting board to be solved readBoard(&board); // print board as read in from file printBoard(fpOut, &board, TRUE, FALSE); findAllSolutions(&board); fclose(fpOut); fclose(fpSoln); return (0); }
int main(int argc, char* argv[]) { while (true) { SudokuBoard* board = readBoard(stdin); if (board == NULL) { break; } if (!isValidBoard(board)) { printf("Invalid board.\n"); freeSudokuBoard(board); continue; } SudokuBoard* solved = solveBoard(board); if (solved == NULL) { printf("No solution found.\n"); freeSudokuBoard(board); continue; } drawSudokuBoardSimple(solved); if (solved != board) { freeSudokuBoard(solved); } freeSudokuBoard(board); } return 0; }
int main() { int size = 0; int** board; int i,j; const char testFile[TEST_COUNT][80] = { "board1x1.txt", "board2x2.txt", "board2x2invalid.txt", "board3x3.txt", "board3x3oneextra.txt", "board3x3onemissing.txt", "board3x3emptyline.txt", "board8x8.txt", "board8x8invalid.txt", "board100x100.txt"}; const int testResult[TEST_COUNT] = {1,1,0,1,0,0,0,1,0,1}; const char testReason[TEST_COUNT][80] = {"I 1x1 bez hran je korektní graf", "Korektní graf", "Nekorektní graf", "Korektní graf", "Nekorektní graf: jedna hrana navíc", "Nekorektní graf: jedna hrana chybí", "Nekorektní graf: u jednoho vrcholu chybí sousedi", "Korektní, dostatečně velký graf", "Chybný, dostatečně velký graf", "Korektní, hodně velký graf"}; for(int i=0; i<10; i++){ printf("Test %d\n", i+1); board = readBoard(&size, testFile[i]); if (isKnights(size, board) == testResult[i]) { printf("PASSED\n"); } else { printf("FAILED\n"); printf("DUVOD: %s\n", testReason[i]); } cleanup(size, board); } return 0; }
/* Main */ int main(int argc, char * argv[]) { resizeScreen(); printf("Hello Army!\n\n"); /* Create board */ cell ** board = createBoard(width, height); /* Clear board */ cleanBoard(board); /* Read board from file */ readBoard(board); for (int i = 0; i < 1000; i++) { /* Print board */ printBoard(board); /* Day */ day(board); /* Wait for enter */ char c = getchar(); } /* Delete board */ deleteBoard(board); /* stop the program from exiting */ char c = getchar(); }
int main(int argc, char const *argv[]) { system("clear"); printf("\t ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██████╗ █████╗ \n"); printf("\t ██║██╔═══██╗██╔════╝ ██╔═══██╗ ██╔══██╗██╔═══██╗ ██╔══██╗ \n"); printf("\t ██║██║ ██║██║ ███╗██║ ██║ ██║ ██║██║ ██║ ╚█████╔╝ \n"); printf("\t ██ ██║██║ ██║██║ ██║██║ ██║ ██║ ██║██║ ██║ ██╔══██╗ \n"); printf("\t ██ ██║██║ ██║██║ ██║██║ ██║ ██║ ██║██║ ██║ ██╔══██╗ \n"); printf("\t ╚█████╔╝╚██████╔╝╚██████╔╝╚██████╔╝ ██████╔╝╚██████╔╝ ╚█████╔╝ \n"); printf("\t ╚════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚════╝ \n"); // Entrada BOARD *board = (BOARD*)malloc(sizeof(BOARD)); STATE *game = createState(); createBoard(&board); readBoard(&board); game->current = board; // Fila inicial PRIORITY_QUEUE *queue = createQueue(); insert(queue, game); // Loop de jogo gameLoop(queue); return 0; }
int main(int argc, char* argv[]) { int width, height; int** board; FILE* file; struct Queue* changeQueue; if (argc!=2) { printf("the right usage is: life <board file>\n"); return WRONG_ARGUMENTS; } /*open board file*/ file = fopen(argv[1], "r"); if (file==NULL) { printf("error in openning the board file\n"); return FILE_OPEN_ERROR; } board = readBoard(file, &width, &height); /*close board file*/ if (fclose(file) != 0) { free(board); return FILE_CLOSE_ERROR; printf("error in closing the board file\n"); } if (board==NULL) { return FILE_FORMAT_ERROR; } changeQueue = newQueue(); /*print initial state*/ system("cls");/*clear the screen*/ printBoard(board, width, height); Sleep(2000); /*game math*/ while (1) { calcChange(board, width, height, changeQueue); flip(board,changeQueue); system("cls");/*clear the screen*/ printBoard(board, width, height); Sleep(1500); } /*doesn't really get here because it's an infinte loop*/ deleteQueue(changeQueue); freeBoard(board,height); return 0; }
bool CsaReader::read(std::istream& is, Record& record, RecordInfo* info/* = nullptr*/) { Board board; // 局面の読み込み if (!readBoard(is, board, info)) { return false; } record.init(board); // 指し手の読み込み if (!readMoves(is, record)) { return false; } return true; }
int main(int argc, char **argv){ int **board = readBoard(); printSudoku(board); printSudoku(solveSudoku(board, newSq(0,0))); }