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

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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