Code:#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #define MAX_STRING_LEN 80 void gameBoard(); int checkWinner(); void computerPlayer(); int size, test, row, col, turn, option2 = 0; char board[15][15]; char alpha[] = {"abcdefghijklmnopqrstuvwxyz"}; int main() { int size, num, test, row, col, turn, option2 = 0; char move; move = num; move = alpha; while(size < 2 || size > 9) { printf("Qual o tamanho da tabela (2...9) : "); scanf("%d", &size); if( size < 2 || size > 9) printf("Tente de novo"); else break; } while(option2 = -1) { if(turn%2 == 0) { int condition = 1; while(condition == 1) { for(int rows = 0; rows < size; rows++) { for(int cols = 0; cols < size; cols++) { board[rows][cols] = '+'; scanf("%d %d", &row, &col); } printf("/n"); } //Program crashses here because I do not know how to input the move correctly printf("Escolha os pontos para conectar (a1-b1 ou 1a-b1): "); scanf("%c", &move); if(board[row][col] == ' ') { board[row][col] = '-'; turn++; condition = 0; } else printf("Jogada invalida/n"); } } else//AI must do something { computerPlayer(); turn++; } if(checkWinner() == 1) //X wins { printf("Parabens vc ganhou/n/n"); option2 = -1; } else if(checkWinner() == 2) //X wins { printf("Voce perdeu/n/n"); option2 = -1; } gameBoard(); } system("PAUSE"); return0; } //****************************************************Functions //print the board to the screen void gameBoard() { printf("/n"); for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { printf("+", board[i][j], "+"); } printf("/n"); } } //************************************************************** int checkWinner() { //check to see if '-' if(board[0][0] == '-' && board[0][1] == '-' && board[0][2] == '-') return 1; if(board[1][0] == '-' && board[1][1] == '-' && board[1][2] == '-') return 1; if(board[2][0] == '-' && board[2][1] == '-' && board[2][2] == '-') return 1; if(board[0][0] == '-' && board[1][0] == '-' && board[2][0] == '-') return 1; if(board[0][1] == '-' && board[1][1] == '-' && board[2][1] == '-') return 1; if(board[0][2] == '-' && board[1][2] == '-' && board[2][2] == '-') return 1; if(board[0][0] == '-' && board[1][1] == '-' && board[2][2] == '-') return 1; if(board[2][0] == '-' && board[1][1] == '-' && board[0][2] == '-') return 1; //check to see '|' if(board[0][0] == '|' && board[0][1] == '|' && board[0][2] == '|') return 0; if(board[1][0] == '|' && board[1][1] == '|' && board[1][2] == '|') return 0; if(board[2][0] == '|' && board[2][1] == '|' && board[2][2] == '|') return 0; if(board[0][0] == '|' && board[1][0] == '|' && board[2][0] == '|') return 0; if(board[0][1] == '|' && board[1][1] == '|' && board[2][1] == '|') return 0; if(board[0][2] == '|' && board[1][2] == '|' && board[2][2] == '|') return 0; if(board[0][0] == '|' && board[1][1] == '|' && board[2][2] == '|') return 0; if(board[2][0] == '|' && board[1][1] == '|' && board[0][2] == '|') return 0; } //************************************************************* //This function generates a random move and see if it's available. if it is, then make it //if it isn't then generate another random move void computerPlayer() { col = -1; row = -1; while(col == -1 || row == -1) { time_t seconds; time(&seconds); srand((unsigned int) seconds); col = rand()%3; row = rand()%3; if(board[row][col] != ' ') { col = -1; row = -1; } board[row][col] = '-'; } }