#include <iostream>
using namespace std;
//function prototypes
void showBoard(char[][3]);
bool checkWinner(char[][3], char);
void playerMove(char[][3], char);
int main()
{
//declare variables needed
//declare 2D array for the board
//and initialize with all *
char board[3][3] = {{'*', '*', '*'},
{'*', '*', '*'},
{'*', '*', '*'}};
int moves = 0; //variable to keep track
//of number of moves
//to determine tie
cout << "TIC - TAC - TOE\n\n";
//while loop to repeat until 9 moves are done
while(true){
//display board
showBoard(board);
cout << "Player 1 moves\n";
//get player X move
playerMove(board, 'X');
//increment moves counter
moves++;
//if this is a winning move
//store winner and terminate
if(checkWinner(board, 'X')){
showBoard(board);
cout << "\nPlayer 1 (X) wins!\n";
return 0;
}
//if 9 moves are done
//break from loop
if(moves == 9)
break;
//display board again
showBoard(board);
cout << "Player 2 moves\n";
//do the same thing for player O
playerMove(board, 'O');
moves++;
if(checkWinner(board, 'O')){
showBoard(board);
cout << "\nPlayer 2 (O) wins!\n";
return 0;
}
}
//if we have gone this far and program
//still has not terminated (no winner)
//it means this is a tie
showBoard(board);
cout << "This game is a tie!\n";
//return 0 to mark successful completion of program
return 0;
}
//this function is helpful because we need to show
//the board repetitively during the program
void showBoard(char board[][3]){
cout << endl;
//loop on the rows
for(int row = 0; row < 3; row++){
//loop on the columns
for(int col = 0; col < 3; col++)
cout << board[row][col] << " ";
//display newline after each row
cout << endl << endl;
}
cout << endl;
}
//this function checks if second argument
//is a winning player
bool checkWinner(char board[][3], char player){
//boolean variable to check
//for winner later
bool flag;
//CHECK FOR WINNER IN ROWS
for(int row = 0; row < 3; row++){
//initialize flag to true
flag = true;
//loop within a row
for(int col = 0; col < 3; col++){
//Notice that the right part of the
//assignment operator, is an expression
//with a relational operator (==)
//this expression will yield either
//true (1) or false (0)
//while flag is already true (1)
//if multiplied by true (1) will result
//in true(0), or multiplied by false (0)
//will result in false (0)
flag *= (board[row][col] == player);
}
//after checking within row, if the flag
//is still true at this point, it means we have
//three chars of the same kind within the row,
//thus we have a winner
if(flag)
return true;
else
continue;
}
//CHECK FOR WINNER IN COLUMNS
//using a similar logic
for(int col = 0; col < 3; col++){
flag = true;
for(int row = 0; row < 3; row++){
flag *= (board[row][col] == player);
}
if(flag)
return true;
else
continue;
}
//CHECK FIRST DIAGONAL (row = col)
//reset flag to true
flag = true;
//check diagonal
for(int i = 0; i < 3; i++){
flag *= (board[i][i] == player);
}
//check if there is winner
if(flag)
return true;
//CHECK OTHER DIAGONAL (row = 2 - col)
//reset flag to true
flag = true;
//check diagonal
for(int col = 0; col < 3; col++){
flag *= (board[2-col][col] == player);
}
//check if there is winner
if(flag)
return true;
//if all of these have been checked
//and function still has not returned,
//it means there is no winner
return false;
}
//this function gets a move from the player,
//checks if it is valid, and if yes it puts
//it on the board
void playerMove(char board[][3], char player){
//variables to store user move
int row, col;
//get user move
cout << "Row: ";
cin >> row;
cout << "Col: ";
cin >> col;
//check if this is valid move
//you have to check if that tile has
//already been marked, or if tile
//of choice is out of bounds of board
while(board[row-1][col-1] != '*' ||
row > 3 || row < 0 ||
col > 3 || row < 0)
{
cout << "Invalid move! Try again\n";
cout << "Row: ";
cin >> row;
cout << "Col: ";
cin >> col;
}
//after validation, mark new move
board[row-1][col-1] = player;
}
Answer:
if on edgen. The answer is c
Explanation:
For each of the following agents, describe all the possible PEAS (Performance, Environment, Actuators, and Sensors) and then identify the environment type. Self-vacuum cleaner Speech recognition device Drone searching for a missing person Computer playing chess Alexa/Siri performing as a smart personal assistant.
The PEAS environment type is a task environment space that is used in the evaluation of performance, the environment, the sensors and the actuators.
How to identify the environment typeFor all of the options listed here, the environment types have to be put in tables. The table has been created in the attachment I added.
The use of PEAS helps in the performance of tasks in an independent way.
Read more on performance evaluator here: https://brainly.com/question/3835272
9.11: Array Expander
Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is twice the size of the argument array. The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0. The function should return a pointer to the new array. Demonstrate the function by using it in a main program that reads an integer N (that is not more than 50) from standard input and then reads N integers from a file named data into an array. The program then passes the array to your array expander function, and prints the values of the new expanded array on standard output, one value per line. You may assume that the file data has at least N values.
Prompts And Output Labels. There are no prompts for the integer and no labels for the reversed array that is printed out.
Input Validation. If the integer read in from standard input exceeds 50 or is less than 0 the program terminates silently.
The Array Expander is an illustration of arrays and functions.
Arrays are variables that stores multiple valuesFunctions are named statements that are executed when calledThe Array Expander programThe Array Expander program written in C++, where comments are used to explain each action is as follows:
#include <iostream>
using namespace std;
//This declares the Array Expander function
int* ArrayExpander(int *oldArr, int size){
//This declares the new array
int *newArr = new int[size * 2];
//This iteration sets values into the new array
for (int i = 0; i < size * 2; i++) {
if(i < size){
*(newArr+i) = *(oldArr+i);
}
else{
*(newArr+i) = 0;
}
}
//This returns a pointer to the new array
return newArr;
}
//The main method begins here
int main(){
//This declares the length of the array, N
int N;
//This gets input for N
cin>>N;
int initArr[N];
//If N is between 1 and 50
if(N > 0 && N <=50){
//This iteration gets values for the array
for(int i = 0; i<N; i++){
cin>>initArr[i];
}
//This calls the Array Expander function
int *ptr = ArrayExpander(initArr, N);
//This iteration prints the elements of the new array
for (int i = 0; i < N*2; i++) {
cout << ptr[i] << " ";
}
}
return 0;
}
Read more abou C++ programs at:
https://brainly.com/question/27246607
positive and negative of adblock plus
Answer:
Pros and cons of ad blockers
Remove distracting ads, making pages easier to read.
Make web pages load faster.
Keep advertisers from tracking you across websites.
Reduce bandwidth (especially important with mobile devices)
Reduce battery usage (again, important for mobile devices)
p
How many bytes/second is a 16Mbps cable modem connection?
Answer:
data transfer rate converter computer connection speed cable modem online converter page for a specific...cable modem to megabit per second(Mbps)
6. What are the arguments, pros and cons, for Python's use of indentation to specify compound statements in control statements
Answer:
[tex]beinggreat78~here~to~help.[/tex]
In some cases, one con is that it can be hard to keep track of your identation when coding long lines or blocks. The pro is that you may need to learn, which is not a bad thing. Learning is good.
what does the GPU do?
Answer:
With graphics processing units (GPU), many pieces of data can be processed simultaneously, which makes them useful for applications such as machine learning, editing, and gaming. It is an electronics circuit capable of accelerating the processing of images, animations, and videos.
Explanation:
how to Develop Administrative Assistant Skills
Answer:
Multitasking, Flexible and resourceful.
Explanation:
im not sure what your asking for but to be or i dont now how to explain to good but hope you get what im mean it no brainier
Two gamers are programming each player in a football team to throw a football
across the stadium at a specific speed to arrive at the running back's hand. Which is
the parameter and which is the argument in the code below?
The parameter and argument are the same, speed by 5 or 2
The parameter is speed, the argument is 5 or 2
The parameter is 5 or 2, the argument is speed
There are no parameters or arguments
The parameter and the argument in the code below is that the parameter is speed, the argument is 5 or 2.
Can programmers be said to be gamers?Gaming is known to be a kind of starting point for new set of programmers as a lot of game designers do uses different kinds of skills.
Note that in the above scenario, it the parameter is speed, the argument is needs to be 5 or 2 for it to work well.
Learn more about code from
https://brainly.com/question/25605883
Which of the following are vector graphic file formats? Choose all that apply.
AI
PNG
RAW
SVG
Please help
There are different kinds of files. The option that is a vector graphic file formats is SVG.
What are vector files?Vector files are known to be a type of images that are created by using mathematical formulas that stands as points on a grid.
The SVG is known as Scalable Vector Graphics file and it is known to be a vector image file format as it make use of geometric forms such as points, lines, etc.
Learn more about vector graphic file from
https://brainly.com/question/26960102
Answer:
AI and SVG
Explanation:
learned it from a comment i give all credit to them
12.2 E-Z LOAN
A loan obtained from a lending institution is typically paid off over time using equal monthly payments over a term of many months. For each payment, a portion goes toward interest and the remaining amount is deducted from the balance. This process is repeated until the balance is zero. Interest is calculated by multiplying the current balance by the monthly interest rate, which is usually expressed in terms of an Annual Percentage Rate (APR). This process produces an Amortization Schedule where the amount applied to interest is gradually reduced each month and the amount applied to the balance grows. For example, the following amortization schedule is for a loan of $ 10.000 at an APR of 3.9% over a term of 30 months:3 will match months 12, 24, and 30 respectively.
Following an amortization schedule, the monthly payments will be $350.39 and the total payment in 30 months will be $10511.7.
How much should be paid monthly to complete loan payment in 30 months?The loan payment follows an amortization schedule where the amount applied to interest is gradually reduced each month and the amount applied to the balance grows.
The amounts to be paid is calculated using the amortization formula:
P = a ÷ {{[(1 + r/n)^nt] - 1} ÷ [r/n(1 + r/n)^nt]}where
P is monthly paymenta is credit amountr is the interest ratet is the time in yearsn is number of times the interest is compoundedFor the loan of $10000;
a = $10000r = 3.9% = 0.039nt = 30 monthsHence,
P = $10000 ÷ {{[(1 + 0.039/12)^60] - 1} ÷ [0.039/12(1 + 0.0.039/12)^60]}
P = $350.39 per month
Total payment in 30 months = $350.39 × 30 = $10511.7
Therefore, the monthly payments will be $350.39 and the total payment in 30 months will be $10511.7.
Learn more about amortization schedule at: https://brainly.com/question/26433770
One problem with backlighting is that your subject may squint.
True
False
Answer:
I would say that's False. Backlighting would be behind them. So they wouldn't need to squint.
Explanation:
What is a value which we pass to the function to use in place of the parameter when we call it?
A. Parameter
B. Call
C. Procedure
D. Argument
How many intrusion switches are there in Dell Precision Tower 7920?
The number of intrusion switches in Dell Precision Tower 7920 is one.
What is an intrusion switch?There is an chassis intrusion switch that is often used in the detection of any unauthorized access that is found stepping into the interior of one's system.
This kind of switch is known to be often activated quickly when the system cover is removed and access is done or made to the interior of one's system.
Learn more about intrusion switch from
https://brainly.com/question/24369537
what is computers machain?
Answer:
the electronic device which take data process it and give meaningful results is called computer machine
explains why it is important to select the correct data when creating a chart
Answer:
to be organized
Explanation:
because when you are organized to select the correct data, you won't confusedType the correct answer in the box. Spell all words correctly.
Craig has told his team to design a website, but he wants to see a fully laid out detailed version before functionality can be added. How can his team produce this?
Craig's team can demonstrate this by creating a(n) {----------}
.
Answer:
A project scope
Explanation:
I just took this on plato
The team designs the website according to the team leader by a project scope.
What is a website?The website is a set of web pages located under a single domain name, generated by a single person or any organization.
Craig has told his team to design a website, but he wants to see a fully laid out detailed version before functionality can be added.
A project can be introduced to create a website for the team members whether individually or in a team.
Thus, the team produce this by a project scope.
Learn more about website.
https://brainly.com/question/19459381
#SPJ2
What year was internet inverted
[tex]\large\blue{\mid{\underline{\overline{\tt { →\:January \:1, 1983}\mid}}}}[/tex]
ARPANET→Advanced Research Projects Agency Networkthe forerunner of the Internet.[tex]\purple{\rule{15mm}{2.9pt}} \red{\rule18mm{2.5pt}} \orange{ \rule18mm{2.5pt}}[/tex]
[tex]\sf{\:мѕнαcкεя\: ♪...}[/tex]
Identify three (3) general-purpose computing devices and write a short (no more
than one page) essay explaining in detail the computing process
The three (3) general-purpose computing devices used around the world are:
Desktop computersSmartphoneTabletWhat is computing?Computing refers to a process which involves the use of both computer hardware and software to manage, analyze, process, store and transmit data, so as to complete a goal-oriented task.
In Computer technology, a general-purpose computing device is a type of computer that can perform most common computing tasks when provided with the appropriate software application. Thus, three (3) general-purpose computing devices include the following:
Desktop computersSmartphoneTabletRead more on computing here: https://brainly.com/question/19057393
Steps of booting a computer
I need help with these certain questions on my activities in school
Answer:
*part 3 multiple choice*
1 d. none of the above
2d. water
3 a. insulator
*The Other Part*
4. electrons change direction of flow frequency in ""alternating current""
2. conductors
Fumiko is a network technician. She is configuring rules on one of her company's externally facing firewalls. Her network has a host address range of 192.168.42.140-190. She wants to allow all hosts access to a certain port except for hosts 188, 189, and 190. What rule or rules must she write
The rule that she must write is that A single rule allowing hosts 140–187 is all that is necessary; the default-deny rule takes care of blocking the remaining nonincluded hosts.
What is a Firewall?A firewall is known to be a form of a network security device that helps one to manage, monitors and filters any form of incoming and outgoing network traffic.
This is often done based on an firm's formerly set up security policies. A firewall is known as the barrier that exist between a private internal network and the public Internet.
See options below
What rule or rules must she write?
a) A single rule allowing hosts 140–187 is all that is necessary; the default-deny rule takes care of blocking the remaining nonincluded hosts.
b) Multiple rules are necessary for this configuration; one or more rules must define Deny exceptions for 188, 189, and 190, followed by the Allow rule for the 140–190 range.
c) A Deny rule is needed for 188, 189, and 190, and then exception rules for the 140–187 range.
d) The default Deny all rule needs to be placed first in the list, and then an exception rule for the 140–187 range.
Learn more about firewalls from
https://brainly.com/question/13693641
Write a function named count_vowels that accepts two arguments: a string and an empty dictionary. The function should count the number of times each vowel (the letters a, e, i, o, and u) appears in the string, and use the dictionary to store those counts. When the function ends, the dictionary should have exactly 5 elements. In each element, the key will be a vowel (lowercase) and the value will be the number of times the vowel appears in the string. For example, if the string argument is 'Now is the time', the function will store the following elements in the dictionary: 'a': 0 • 'e': 2 'i': 2 'o': 1 'u': 0 The function should not return a value.
The function that counts the number of times a vowel exist in a string is as follows:
def count_vowels(string, dictionary):
vowels = 'aeiou'
dictionary = {}.fromkeys(vowels, 0)
for i in string:
if i in vowels:
dictionary[i] += 1
return dictionary
print(count_vowels("trouble", {}))
Code explanation.The code is written in python.
we defined a function named "count_vowels". The function accept a string and an empty dictionary.Then. we store the vowels in a variable vowels.The dictionary is used to store the key value pair i.e the vowels and the number of times they appear.We looped through the string.If any value in the string is in vowels, we increase the dictionary values by 1.Then, we return the dictionary.Finally, we call the function with it parameters.learn more on function here: https://brainly.com/question/27219031
Which evidence best addresses the counterclaim?
a story about a girl who becomes a professional athlete after she graduates
quotations from teens and parents who fight with coaches
a story about a boy who gets bad grades because he plays too many sports
an example of how sports may lead to many injuries
an exclamation point
an exclamation point
Answer:
A. a story about a girl who becomes a professional athlete after she graduates
Explanation:
i hope this helped
which is considered both an input and output device?
A) Keyboard
B) Microphone
C) Speaker
D) Touchscreen Monitor
Please hurry :3 15 points
Answer:
speaker
Explanation:
its the one that gives sounds
Answer:
The answer would be D) Touchscreen Monitor
Explanation:
A Touchscreen monitor (such as a smartphone screen) outputs information to the user, while also recieving information from the user.
These are raised as livestock for meat and milk EXCEPT one
A. Hog
B. Goat
C. Carabao
D. Cattle
The livestock that is not raised for meat and milk is hog.
What are animals raised for meat?Livestock are known to be some domesticated animals that are said to be raised in an agricultural farm to give labor and produce things such as meat, eggs, milk, etc.
The animals that are raised for their meat and milk are:
Boar BroilerCattle, etc.Learn more about animals from
https://brainly.com/question/25897306
20) Which of the following functions would take the word "Joe" (found in column A) and "Smith" (found in column B), and display "Joe Smith" in column C?
A. COMBINETEXT
B. TEXTJOIN
C. JOINTEXT
D. JOIN
Answer:
TEXTJOIN
Explanation:
TEXTJOIN is a common function of Ms Excel or Microsoft ExcelThis function requires three arguments
delimiterignore_empty text1.Answer:
TextJoinExplanation:
Is the functions would take the word "Joe" (found in column A) and "Smith" (found in column B), and display "Joe Smith" in column C.
i need the full code for 6.1.3 code hs circles and squares please answer please help
In this exercise we have to use the knowledge in computational language in python to write a code with circles and squares.
how to draw geometric figures in python?inputs = 100
radius
draw_circle(radius);
pendown()
begin_fill()
circle(radius)
end_fill()
penup()
left(90)
forward(radius*2)
right(90)
penup()
setposition(0,-200)
color("gray")
bottom_radius = int(input("What should the radius of the bottom circle be?: "))
draw_circle(bottom_radius)
draw_circle(bottom_radius)
See more about python at brainly.com/question/18502436
Mike logged into a shopping website and entered his username and password. Which protocol will the website use to verify his credentials?
Answer:
I think it is email or password
Write multiple if statements:
If carYear is before 1967, put "Probably has few safety features.\n" to output.
If after 1970, put "Probably has head rests.\n" to output.
If after 1992, put "Probably has anti-lock brakes.\n" to output.
If after 2002, put "Probably has airbags.\n" to output.
Ex: If carYear is 1995, then output is:
Probably has head rests.
Probably has anti-lock brakes.
Hope this is good enough! Good luck.
Use HTML and CSS, create a web page for the table shown below. Please copy (and paste) your code from your text editor (Replit).