Write a program that plays a tic-tac-toe game.

Assignment Help C/C++ Programming
Reference no: EM13159228

Using functional decomposition, write a program that plays a tic-tac-toe game. Ask the user if they want to go first; the player (user or computer) that goes first is designated X and the other player is O. The board is represented by three one-dimensional arrays (a, b, and c) each with three members (0, 1, 2). The players take turns making moves by designating a letter and a number; e.g., a1. Each player's move must be evaluated to make sure it is valid (within the range and not already occupied). If the user makes a bad move, tell them and ask for another move. If the computer makes an invalid move, keep getting a move until one is valid

In this game, the computer is not intelligent; its moves are random.

A player wins if they occupy three positions in a row; e.g., a1, b1, and c1, or a0, a1, and a2, etc.. Don't forget diagonals.

Before the game starts and after each valid move, show the user the board. Use a combination of spaces, dashes, and vertical lines.

The game ends when a player wins or the maximum number of moves has occurred. If the maximum number of moves takes place and there is no winner, the game is a tie. Tell the user what the result is (winner or tie).

When the game is over, ask the player if they want to play again. If yes, clear the board and start again; if no, say good bye and exit.

Use functions as appropriate.

 

 

Reference no: EM13159228

Questions Cloud

How did this likely affect labours share in national income : Does an increase in the average annual labour income imply that the individual worker's labour income has increased and
How does the hiv virus make new viral proteins : How does the HIV virus make new viral proteins and viral genomes, Which of these processes are carried out by viral vs. human enzymes/structures? How does the virus get out again or be totally eliminated from the body? Remember to focus on the flo..
Family-status of children-role of women : Research what a person would need to know in order to visit your country successfully. In your search, look for topics such as family, status of children, role of women, role of the aged, customs,
Fair-value of identifiable net assets : In a business combination accounted for as an acquisition, how should the excess of fair value of identifiable net assets acquired over implied value be treated?
Write a program that plays a tic-tac-toe game. : Using functional decomposition, write a program that plays a tic-tac-toe game.
Correct example of inheritance : Which of the following relationships is not a correct example of inheritance?  Parent to Children  Aunt to Uncle  Grandparent to Grandchild
What is a marketing information system : What is a marketing information system and what should it provide? How is the value of a marketing information system measured?
What is the change in the number of unemployed people : What is the change in the number of unemployed people in this particular month and what is the change in the number of  employed people  in the same period?
Competitive intelligence activities : What competitive intelligence activities can technology help a company to perform better? Are there limitations? Which ones will you choose for which industries? Explain

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write and test c program which outputs waveform

Write and test a C program which outputs waveform which switches from 10.0 kHz with a 50% duty cycle to 25.0 kHz with a 5% duty cycle every 5 seconds.

  Program to produce ten random permutations of numbers

In C++(must be able to compile in Visual Studio ): Write a program to produce ten random permutations of numbers 1 to 10.

  Draws a single level for a "rogue­like" computer game

You will write a program that draws a single level for a "Rogue­like" computer game. The program will parse a line of input text from an input file (room.txt), use the parsed text to determine the shape of the room and its contents and then draw the ..

  Prepare a businesspartner

Prepare a BusinessPartner class that contains a company name, first name and a telephone number.

  Write c program to add two integers and prints out average

Write a C program that prompts for a variable number of integers, adds them up, and prints out the average. The user will enter either an integer to be averaged.

  Write program function prompt user for number of elements

Write a C++ program main function which will prompt the user for the number of elements called N desired for an array which has the capacity to store 50 elements.

  Describe the probability of the moves

Write a program in C++ to describe the Probability of the moves

  Program to output value of tenth component of array

Write a C++ statements to perform the following: Set value of fourth component of array alpha to three times  value of eight component minus 57.

  Design and write a c++11/fltk game program

The project is to design and write a C++11/FLTK game program with a graphical user interface. The game is based on "pancake sorting," which actually has some mathematical significance.

  Design customized mailing lists for marketing department

Marketing department requires to be able to design customized mailing lists, to send different messages to different types of donors. What system will best meet these requirements?

  Implement recursive algorithms using a stack

Show the difficulties of the added complexity and which of the two sorts is easier to implement nonrecursively? Why?

  Write a program to calculate existing angles

Write a program to calculate existing angles and do if and then from this, and to place fixed angles at certain position.

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