Okay. Here are my instructions. I am not allowed to use Arrays.
Instructions:
You are to create a simulation of a tic-tac-toe game. Each position will be generated randomly based on a seed that is input by the user. The program will print the board, determine if it is a valid board (4 pieces of one and 5 of another, at most one winning pattern), and determine if there is a winner.
1) Prompt for and read in nonnegative user seed (function) Possible invalid entry: Ran out of data. Non-int data. Not nonnegative. When the user enters an invalid seed, the program should not process the rest of the program. Do NOT use exit() or abort() builtin functions. Use a Boolean function for getting the seed. 2) Generate board (function) 3) Print board (function) 4) Determine if valid (function) Possible errors: too many Xs or Os too many winning patterns If it is invalid, the program should not process the rest of the program. Use a Boolean function to determine if valid. 5) Determine if winner, and if so, whom, and if so, where. (function) 6) Print whether there is a winner, and if so, whom, and if so, where. (function)And here is the code that I have so far:
My question is how do I do the genBoard() function and the printBoard() function? Also, is the code that I have so far correct?Code:#include <stdio.h>#include <stdbool.h>
bool getInput(int* pInput);
int genBoard(int input);
void printBoard(int input, int topRow, int midRow, int bottomRow, int lCol,
int midCol, int rCol, int lDiag, int rDiag);
int ifValid(int input, int topRow, int midRow, int bottomRow, int lCol,
int midCol, int rCol, int lDiag, int rDiag);
int winner(int input, int topRow, int midRow, int bottomRow, int lCol,
int midCol, int rCol, int lDiag, int rDiag);
void display(int input, int topRow, int midRow, int bottomRow, int lCol,
int midCol, int rCol, int lDiag, int rDiag);
int main(void)
{
int input;
int topRow, midRow, bottomRow;
int lCol, midCol, rCol;
int lDiag, rDiag;
bool getInput(int* pInput)
{
bool success = false;
int scanRes;
printf("\nName: Danielle Evans");
printf("\nPlease enter a nonnegative integer seed: ");
scanRes = scanf("%d", input);
if (scanRes == 1)
{
int input = *pInput;
if (input < 0)
{
printf("Not nonnegative. ");
}
else
printf("\nRan out of data. ");
}
else if (scanRes == 0)
printf("\nNon-int data. ");
if(!success)
printf("\n\n");
return success;
}
int genBoard(int input)
{
}
void printBoard(int input, int topRow, int midRow, int bottomRow, int lCol,
int midCol, int rCol, int lDiag, int rDiag)
{
}
int ifValid(int input, int topRow, int midRow, int bottomRow, int lCol,
int midCol, int rCol, int lDiag, int rDiag)
{
}
int winner(int input, int topRow, int midRow, int bottomRow, int lCol,
int midCol, int rCol, int lDiag, int rDiag)
{
}
void display(int input, int topRow, int midRow, int bottomRow, int lCol,
int midCol, int rCol, int lDiag, int rDiag)
{
}
return 0;
}
Thanks

