Write a function that determines who has won a game of tic-tac-toe. The function should receive a
Fantastic news! We've Found the answer you've been seeking!
Question:
Write a function that determines who has won a game of tic-tac-toe. The function should receive a character array containing the moves of tic-tac-toe game as given below. first check all rows to see whether one player occupies all the cells in one row, next check all columns, and then check the two diagonals. The function should return a value of 1, 0, -1 in case player 1 wins, draw and player 2 wins, respectively. Assume player 1 marks ‘o’ and player 2 marks ‘x’. Assume, the position for no-move contains ‘ ’ (space character)
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
Write a function that will blend three sounds together. Start with part of the first sound, then a blend of sound1 and sound2, and then a blend of sound2 and sound3, and end with the rest of sound3.
-
Write a function that takes parameters r1 , r2 , n and generates random points (x1,x2) as follows - n random points that lie within a circle with center at (0,0) and radius r1 These points belong to...
-
Write a function that takes two integer inputs and returns the sum of all even numbers between these inputs, and another function that takes two integer inputs and returns the sum of odd numbers...
-
After deducting capital allowances for the year to 31 December 2019, the tax written down values of a company's plant and machinery were as follows: Calculate the capital allowances available for the...
-
Water World sells three products: ski vests, slalom skis, and ski ropes. Information related to each product line is provided below: The companys annual fixed costs are approximately $741,000. a....
-
We will soon stop talking of e-commerce and simply speak of commerce. Why?
-
Can a company launch an offer to buy another company that is for sale without having any real intention of closing the deal? Why? What protection is there for the seller?
-
The following are specific balance-related audit objectives applied to the audit of accounts receivable (a through h) and management assertions about account balances (1 through 4). The list referred...
-
You are to design an experiment to simulate shooting free throws for a player who makes 80% of her free throws on average. (a) How could you do the simulation using a number of tiles drawn from a...
-
MSK Construction Company contracted to construct a factory building for $525,000. Construction started during 20X1 and was completed in 20X2. Information relating to the contract follows: Required:...
-
IIn what ways can a school counselor address his or her mental health needs to facilitate healthy counseling practices in their school setting? Why is this such an important topic? What can the...
-
In Fiscal year 2018, Firm A had a revenue of 12.42M, gross profit of 7.46M, and net income of 4.84M. Firm B had a gross profit margin of 54%, Revenues for 66.7M and its difference between gross...
-
12-36. Suppose that a national health club chain investigated how many pounds heavier club members were than their perceived ideal weight. It investigated whether these perceptions differed among...
-
On April 1, Manda Company had the following balances in its inventory accounts: Materials Inventory $ 12,450 Work-in-process Inventory 22,605 Finished Goods Inventory 4,600 Work-in-process inventory...
-
Bolder Chemicals limited manufactures a product, Zander, within two separate processes.For the week ended September 24, 2019 the details were: Process 1 Materials input, 4000kilos @$3 per kilo Labour...
-
Investment manager Max Gaines has several clients who wish to own a mutual fund portfolio that matches, as a whole, the performance of the S&P 500 stock index. His task is to determine what...
-
Homework for Chapter 3: Problem #1 in the text (Chapter 3) Sweet Dreams Corp. Income Statement For the Year Ended Dec. 31 2017 Sweet Dreams Corp. Balance Sheet As of Dec. 31 2017 Sales 2017 2016...
-
Test your confidence in the following Project Decisions: SI. # Question 01 02 03 04 05 06 07 08 09 10 How many years did it take to construct the largest Egyptian Pyramid- Pyramid of Cheops? When was...
-
Advertisers use several types of publicity mechanisms. Look through some recent newspapers and magazines or use an Internet search engine and identify a news release, a feature article, or a...
-
For most people, surfing and skateboarding come to mind immediately when they think of southern California culture. For 40 years, Vans has embodied the California lifestyle and remains one of the...
-
Copy, the verbal portion of advertising, is used to move readers through a persuasive sequence called AIDA: attention, interest, desire, and action. To achieve this, some copywriters have adopted...
Study smarter with the SolutionInn App