Display History2
unknown
c_cpp
2 years ago
2.0 kB
8
Indexable
void displayHistory(char* history, int numOfMoves) { //BEGIN TODO enum Stone hist[15][15]; char option; int i = 0 ; bool player1Turn = true; while (true) { // input and check if the move is valid prinf('%s',inputCommand); while (true) { scanf('%s',option); //TH đang ở nước đi cuối cùng và nhập 'n' if (option=='n' && i==strlen(history)-1) { printf('%s',endOfHistory); continue; } //TH đang ở nước đi đầu tiên và nhập 'p' else if (option=='p' && i==0) { printf('%s', startOfGame); continue; } else if (option=='s') { return; } else { prinf('%s', invalidInput); continue; } break; } // Move to next move if (option=='n') { int k=i; while ( ( int(history[k])< 57 ) and ( int(history[k]) > 48 ) ) //interating through number in history { k++; } char move[5]; memcpy(move, &history[i],(k-i)+1); makeMove(hist, MAX_SIZE, MOVE, player1Turn); player1Turn=!player1Turn; } // Delete the move else if (option=='p') { int k=i-2; // move back past the 'char' while ( ( int(history[k]) < 57 ) and ( int(history[k]) > 48 ) ) { k--; } char move[5]; memcpy(move, &history[k],(i-k)+1); char *ptr; //delete the move hist[ strol(move,*ptr,10) ][ int(history[i-1]) -97]=NA; player1Turn=!player1Turn; } } //END TODO }
Editor is loading...