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...
-
Explain what is meant by the notion of "trimming" a multiple regression result. Use the following example to illustrate your understanding of this concept. A bicycle manufacturer maintains records...
-
The College Board SAT college entrance exam consists of three parts: math, writing, and critical reading (The Wall Almanac, 2012). Sample data showing the math and writing scores for a sample of 12...
-
Explain the significance of collection class and provide two examples.
-
Hinske Company had the following transactions during April. 1. Sold merchandise on account. 2. Purchased merchandise on account. 3. Collected cash from a sale to Renfro Company. 4. Recorded accrued...
-
Following are the transactions of a new company called Pose-for-Pics. August 1 M. Harris, the owner, invested $10,500 cash and $45,150 of photography equipment in the company in exchange for common...
-
A manufacturer of a new Smart Watch claims that the probability of its watch running more than 1 minute slow or 1 minute fast after 1 year of use is .05. A consumer protection agencyhas purchased...
-
The balance sheet and income statement shown below are for XYZ Inc. Note that the firm has no amortization charges, it does not lease any assets, none of its debt must be retired during the next 5...
-
John Jefferson dies on November 10, 2019. John is on the cash basis of accounting for tax purposes. On November 29, 2019, a $4,000 paycheck covering the period November 1 November 8, 2019, is mailed...
-
Mary Beth is a CPA, devoting 3,000 hours per year to her practice. She also owns an office building in which she rents out space to tenants. She devotes none of her time to the management of the...
-
Richard Johnson held $50,000 of U.S. government savings bonds on the date of his death, December 11, 2019. The bonds mature in 2020. Unreported interest income on these bonds at the date of Richard's...
-
The trust instrument requires the trustee to distribute $40,000 annually to Carl Smith, the grantor's son. Any residual income may be distributed or accumulated for Bob Jones, Sam Smith, Earl Litt,...
-
Hershel Barker was the president and majority shareholder in Bulldog Inc. He was a cash-basis taxpayer who reported his income on a calendar-year basis. On March 1, 2019, Hershel was killed in a...
-
4. Design Mod-6 synchronous down counter using T master slave FF. The counter continuously counts, starting from 0, going to 0-5-4-3-2-1-0 and then back to 5. Each FF in the clock cycle In order for...
-
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...
-
Let's consider the harmonic oscillator immersed in a heat bath of temperature \(T\). For any Hermitian operator \(\hat{A}\), we can define its thermal average denoted as...
-
We had established an intriguing relationship between the path integral of the previous chapter and the partition function here through "complexification" of the time coordinate. In this problem, we...
-
An extremely intriguing feature of quantum entanglement is a property that has been called the "monogamy of entanglement": a particle can only be maximally entangled with precisely one other...
Study smarter with the SolutionInn App