Simulation of checking tic-tac-toe board

Assignment Help Programming Languages
Reference no: EM131198930

You must do this assignment correctly as described below. 

If you do not follow the directions or break the rules you will receive a 0 score.

Simulation of checking tic-tac-toe board for wins by counting X and O in rows, columns and diagonals.

in a loop for array sizes 3X3, 4X4, 5X5

Fill the array of characters with either X or O.

Print the array

Count number of X and O in each row, each column and each diagonal and print the totals.

Extra credit (10%) while printing counts print wins for X and/or O

You must correctly use the variables and functions as given below.

You must use the outer for loop that varies the size of the array. 

That size must control the loops that fill, print and count.

All printing of counts must have labels for which row, column or diagonals the counts are for.

You must use loops, as demonstrated in class, to count the X and O in each direction.

Functions:

printArray(char array[5][5], int size) // row by row with label showing size

               int row, col;

countRows(char array[5][5], int size) // prints a count of X and Os for each row extra prints wins

    int row, col, xCount, oCount;

countColumns(char array[5][5], int size) // prints a count of X and O for each column, extra credit prints wins

int row, col, xCount, oCount;

countDiags(char array[5][5], int size)  // prints a count of X and O for both diagonals, extra credit wins

int row, col, xCount, oCount;

// single loop (1) to count top left to bottom right

// print diagonal's counts with label

// single loop (1) to count other diagonal

// print other diagonal's counts with label

int main(intargc, char * argv[] ){

               int row, col, size;

               char array[5][5];

               srand((unsigned)time(NULL)); // seedy stuff

               for (size = 3; size <= 5; size++) {

                        // fill the array

                              for (row = 0; row < size; row++)

                                             for (col = 0; col < size; col++)

                                                            array[row][col] = (rand() % 2) == 0 ? 'X' : 'O';

// print array: printArray(array, size)

 // print each row's counts: countRows(array, size)

  // print each column's counts: countColumns(array, size)

// print both diagonal's counts countDiags(array, size)

               } // end outer array size loop

Hints:

Do it for one size array first.  Do each part and test before moving on to the next.  Get fill and print array working, then rows etc.

Remember size 5 is 0-4 indexes.

Don't forget to reset the xCount and oCount to 0 after each row or column part of the loops.

Once it works for size 3 do it for 3, 4, and 5 using the outer for loop.

Reference no: EM131198930

Questions Cloud

What was the velocity of circulation in 2011 : Fisheria is a country in which the quantity theory of money operates. The country has a constant population, capital stock, and technology. In 2010, real GDP was $300million, the quantity of money was $60million, and the velocity of circulation of..
Supply and demand drive the transportation industry : Please discuss how supply and demand drive the transportation industry? In your opinion, how does the transportation industry affect the environment?
Majority of purchasing organisations : A recent report highlighted that the main measure of performance used by the majority of purchasing organisations was reduced costs.Propose other sets of performance measures that could be applied by purchasing organisations to assess their contri..
Large fraction of us health care costs : The fact that such a large fraction of U.S. health care costs are spent on people in their last six months of life has led many people to call the American health care system "wasteful."- Why might this be an overgeneralization?
Simulation of checking tic-tac-toe board : Simulation of checking tic-tac-toe board for wins by counting X and O in rows, columns and diagonals - You must use loops, as demonstrated in class, to count the X and O in each direction.
Identify the specific government health programs : Select a health policy issue from the list below. Analyze the policy issue using the given criteria. Assume that you must advocate for or argue against the policy issue in front of a Congressional health committee.
Find out the organizational behavior : Colin Powell is a retired four star general and was Commander of the United States Army Forces Command.  He also served as Secretary of State under George W. Bush and was his National Security Advisor.  Listen to Powell talk about Leadership in th..
Find the lowest price at which the product would be supplied : For each 25% increase in the unit price, 200 more calculators are supplied. When the price per calculator is P400, 500 more calculators are supplied.
National health insurance system like canadas : One disadvantage of a national health insurance system such as Canada's is "queuing"-people. - What elements of a national health insurance system could lead to this situation?

Reviews

Write a Review

Programming Languages Questions & Answers

  C program to accept three numbers inputs by user

Write down C program to accept three numbers input by a user, and outputs a table of temperatures in Fahrenheit, Celsius, and Kelvin.

  Program that specialized in solving the equations

Write a program that specialized in solving the equations Ax = b by Doolittle's decomposition method, where A is the hilbert matrix of arbitrary size n x n, and bi = the summation of Aij for j = 1 to n.

  Describe the contents of text box after button is clicked

Describe the contents of the text box after the button is clicked

  Find a way to have only a few fibonacci numbers in memory

Implement an iterative solution that runs in O(n) time and returns a pointer to a HugeInteger struct that contains F(n). Be sure to prevent memory leaks before returning from this function.

  Add a selection list for the state.

nput button that calls function that validates e-mail address by checking for @ sign. If no @ sign is found, display a message.

  Use perl script on window

Use Perl script on window to read in all file in a directory and concatenate them in one big file.

  Assignment on the two-dimensional array sales

Use a two-dimensional array to solve the following problem: A company has four salespeople (1 to 4) who sell five different products (1 to 5). Once a day, each salesperson passesin a slip for each type of product sold. Each slip contains the follo..

  Find the total number of products sold for each product

Find the total number of products sold for each product.

  Define class that contains member variable of type string

Define a class named Document that contains a member variable of type String named text that stores any textual content for the document.

  Create-implement simple class using static variables-methods

This third programming project is intended to demonstrate your knowledge of the following: create and implement a simple class. properly use static variables, methods and constants

  Write down a program to request the user to input a numeric

write a program to request the user to input a numeric value. if the input is even the program will display all the

  Write a paper on memory management

Write a paper on Memory Management

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd