Code:
#include <stdio.h>
#include <stdbool.h>
bool getInput(int* pInput);
int genBoard(int* pTopL, int* pTopC, int* pTopR, int* pCenL,
int* pCenC, int* pCenR, int* pBotL, int* pBotC, int* pBotR);
void printBoard(int* pTopL, int* pTopC, int* pTopR, int* pCenL,
int* pCenC, int* pCenR, int* pBotL, int* pBotC, int* pBotR);
bool ifValid(int topL, int topC, int topR, int cenL, int cenC,
int cenR, int botL, int botC, int botR);
int winner(int topL, int topC, int topR, int cenL, int cenC,
int cenR, int botL, int botC, int botR);
void display(int topL, int topC, int topR, int cenL, int cenC,
int cenR, int botL, int botC, int botR);
int main(void)
{
int input;
int topL, topC, topR;
int cenL,cenC, cenR;
int botL, botC, botR;
if (getInput(&input))
display(topL, topC, topR, cenL, cenC, cenR, botL, botC, botR);
return 0;
}
bool getInput(int* pInput)
{
bool success = false;
int scanRes;
printf("\nName: Danielle Evans");
printf("\nPlease enter a nonnegative integer seed: ");
scanRes = scanf("%d", pInput);
if (scanRes == 1)
{
int input = *pInput;
if (input < 0)
{
printf("Not nonnegative. ");
}
else
{
success = true;
}
}
else if (scanRes == 0)
printf("\nNon-int data. ");
if(!success)
printf("\n\n");
return success;
}
int genBoard(int* pTopL, int* pTopC, int* pTopR, int* pCenL,
int* pCenC, int* pCenR, int* pBotL, int* pBotC, int* pBotR)
{
*pTopL = rand() % 2;
*pTopC = rand() % 2;
*pTopR = rand() % 2;
*pCenL = rand() % 2;
*pCenC = rand() % 2;
*pCenR = rand() % 2;
*pBotL = rand() % 2;
*pBotC = rand() % 2;
*pBotR = rand() % 2;
}
void printBoard(int* pTopL, int* pTopC, int* pTopR, int* pCenL,
int* pCenC, int* pCenR, int* pBotL, int* pBotC, int* pBotR)
{
if ( *pTopL == 0)
{
printf("X");
}
else printf("O");
if ( *pTopC == 0)
{
printf("X");
}
else printf("O");
if ( *pTopR == 0)
{
printf("X");
}
else printf("O");
if ( *pCenL == 0)
{
printf("X");
}
else printf("O");
if ( *pCenC == 0)
{
printf("X");
}
else printf("O");
if ( *pCenR == 0)
{
printf("X");
}
else printf("O");
if ( *pBotL == 0)
{
printf("X");
}
else printf("O");
if ( *pBotC == 0)
{
printf("X");
}
else printf("O");
if ( *pBotR == 0)
{
printf("X");
}
else printf("O");
printf(" %c | %c | %c \n", *pTopL, *pTopC, *pTopR);
printf(" %c | %c | %c \n", *pCenL, *pCenC, *pCenR);
printf(" %c | %c | %c \n", *pBotL, *pBotC, *pBotR);
}
bool ifValid(int topL, int topC, int topR, int cenL,
int cenC, int cenR, int botL, int botC, int botR)
{
int total= topL + topC + topR + cenL + cenC+ cenR + botL + botC + botR;
if(total !=4 && total !=5)
return false;
}
int winner(int topL, int topC, int topR, int cenL, int cenC,
int cenR, int botL, int botC, int botR)
{
}
void display(int input, int topRow, int midRow, int bottomRow, int lCol,
int midCol, int rCol, int lDiag, int rDiag)
{
}