C PROGRAMMING
INCLUDE MAIN FOR TESTING
WILL GIVE RATING![Boards Consider the following depiction of a tic-tac-toe board This board is represented by the 60 character C string: If we consider the Xs to be represented by 2s and the Os by 1s and the blank spaces by Os. We can encode the board above by the base-3 number 2100000003) which is equal to 15,309 Write a function that converts the C string board representation to a base-3 string void boardtob3( char b3(10], char board 60] and a function that converts the base-3 string representation back into a C string board void boardfromb3 char board[60], char b3[10]](http://img.homeworklib.com/questions/6a691dc0-bad4-11ec-9554-79fbcd6bab8b.png?x-oss-process=image/resize,w_560)
/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile
and execute it.
*******************************************************************************/
#include <stdio.h>
#include<string.h>
void boardtob3(char b3[10],char board[60])
{
int i,j;
j=0;
for (i=1;i<30;i++)
{
if
(board[i*2-1]=='X'||board[i*2-1]=='x')
{
b3[j++] = '2';
}
if(board[i*2-1]=='O'||board[i-1]=='o')
b3[j++] = '1';
if(board[i*2-1]=='
')
b3[j++] = '0';
}
}
void boardfromb(char board[60],char b3[10])
{
int i;
//assigning every 11th character of board
nextline
for(i=1;i<5;i++)
{
board[i*12-1] =
'\n';
}
for (i=1;i<=15;i++)
{
if((i*4-1)==11||(i*4-1)==23||(i*4-1)==35||(i*4-1)==47||(i*4-1)==59)
{}
else
board[i*4-1] =
'|';
}
board[59] = '\0';//last character of string is
null character
board[0] = ' ';
if(b3[0]=='0')
board[1] = ' ';
else if(b3[0]=='2')
board[1] = 'X';
else
board[1] = 'O';
board[2] = ' ';
board[4] = ' ';
if(b3[1]=='0')
board[5] = ' ';
else if(b3[1]=='2')
board[5] = 'X';
else
board[5] = 'O';
board[6] = ' ';
board[8] = ' ';
if(b3[2]=='0')
board[9] = ' ';
else if(b3[2]=='2')
board[9] = 'X';
else
board[9] = 'O';
board[10] = ' ';
for(i=12;i<15;i++)
board[i] = '-';
for(i=16;i<19;i++)
board[i] = '-';
for(i=20;i<23;i++)
board[i] = '-';
board[24] = ' ';
if(b3[3]=='0')
board[25] =' ';
else if(b3[3]=='2')
board[25] = 'X';
else
board[25] = 'O';
board[26] = ' ';
board[28] = ' ';
if(b3[4]=='0')
board[29] = ' ';
else if(b3[4]=='2')
board[29] = 'X';
else
board[29] = 'O';
board[30] = ' ';
board[32] = ' ';
if(b3[5]=='0')
board[33] = ' ';
else if(b3[5]=='2')
board[33] = 'X';
else
board[33] = 'O';
board[34] = ' ';
for(i=36;i<39;i++)
board[i] = '-';
for(i=40;i<43;i++)
board[i] = '-';
for(i=44;i<47;i++)
board[i] = '-';
board[48] = ' ';
if(b3[6]=='0')
board[49] = ' ';
else if(b3[6]=='2')
board[49] = 'X';
else
board[49] = 'O';
board[50] = ' ';
board[52] = ' ';
if(b3[7]=='0')
board[53] = ' ';
else if(b3[7]=='2')
board[53] = 'X';
else
board[53] = 'O';
board[54] = ' ';
board[56] = ' ';
if(b3[8]=='0')
board[57] =' ';
else if(b3[8]=='2')
board[57] = 'X';
else
board[57] = 'O';
board[58] = ' ';
}
int main()
{ char b3[10];
int i;
char board[60];
printf("board\n");
for (i=0;i<60;i++)
scanf("%c",&board[i]);
boardtob3(b3,board);
for(i=0;i<10;i++)
printf("%c",b3[i]);
boardfromb(board,b3);
printf("\n");
for(i=0;i<60;i++)
printf("%c",board[i]);
return 0;
}

C PROGRAMMING INCLUDE MAIN FOR TESTING WILL GIVE RATING Boards Consider the following depiction of a...
C programming language Purpose The purpose of this assignment is to help you to practice working with functions, arrays, and design simple algorithms Learning Outcomes ● Develop skills with multidimensional arrays ● Learn how to traverse multidimensional arrays ● Passing arrays to functions ● Develop algorithm design skills (e.g. recursion) Problem Overview Problem Overview Tic-Tac-Toe (also known as noughts and crosses or Xs and Os) is a paper-and-pencil game for two players, X and O, who take turns marking the...
Implement a tic-tac-toe game. At the bottom of these specifications you will see a template you must copy and paste to cloud9. Do not change the provided complete functions, or the function stub headers / return values. Currently, if the variables provided in main are commented out, the program will compile. Complete the specifications for each function. As you develop the program, implement one function at a time, and test that function. The provided comments provide hints as to what...
Implement a tic-tac-toe game. Currently, if the variables provided in main are commented out, the program will compile. Complete the specifications for each function. As you develop the program, implement one function at a time, and test that function. The provided comments provide hints as to what each function should do and when each should be called. Add variables where you see fit. Implementation Strategies: The template has variables and two global constants for you to utilize. The template has...
Write a C++ program, tictac.cpp, that repeatedly reads in tic-tac-toe boards and for each one indicates if there is a winner and who won. The board will be read in as 3x3 array of characters (x, o or . for a blank spot). You are required to write the following functions to help solve the problem: // input prompts the user for a board and inputs it // into the given array void input (char board [3][3]); // print prints...
In a game of Tic Tac Toe, two players take turns making an available cell in a 3 x 3 grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A stalemate occurs when all the cells on the grid have been filled with tokens and neither player has achieved a win. Write a program...
In a game of Tic Tac Toe, two players take turns making an available cell in a 3 x 3 grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A stalemate occurs when all the cells on the grid have been filled with tokens and neither player has achieved a win. Write a program...
In the C++ programming language write a program capable of playing 3D Tic-Tac-Toe against the user. Your program should use OOP concepts in its design. Use Inheritance to create a derived class from your Lab #9 Tic-Tac-Toe class. You can use ASCII art to generate and display the 3x3x3 playing board. The program should randomly decide who goes first computer or user. Your program should know and inform the user if an illegal move was made (cell already occupied). The...
The Code is C++ // tic tac toe game #include <iostream> using namespace std; const int SIZE = 9; int check(char *); void displayBoard(char *); void initBoard(char *); int main() { char board[SIZE]; int player, choice, win, count; char mark; count = 0; // number of boxes marked till now initBoard(board); // start the game player = 1; // default player mark = 'X'; // default mark do { displayBoard(board); cout << "Player " << player << "(" << mark...
I have to create a tic tac toe board using the following classes. The main function is already been made as another java file and presented below to test if it works or not. Using these methods as the public class: public TTTBoard(int size) //Present DEFAULT_SIZE = 3. Throw IllegalArgumentException if the size is less than 1. public TTTBoard() public char get(int r, int c) //Throw IndexOutOfBoundsException if out of bounds public void set(int r, int c, char ch) //Char...
1 Overview For this assignment you are required to write a Java program that plays (n, k)-tic-tac-toe; (n, k)-tic- tac-toe is played on a board of size n x n and to win the game a player needs to put k symbols on adjacent positions of the same row, column, or diagonal. The program will play against a human opponent. You will be given code for displaying the gameboard on the screen. 2 The Algorithm for Playing (n, k)-Tic-Tac-Toe The...