Farmer John has recently acquired NN new cows (3≤N≤5×105)(3≤N≤5×105), each of whose breed is either Guernsey or Holstein.The cows are currently standing in a line, and Farmer John wants take a photo of every sequence of three or more consecutive cows. However, he doesn't want to take a photo in which there is exactly one cow whose breed is Guernsey or exactly one cow whose breed is Holstein --- he reckons this singular cow would feel isolated and self-conscious. After taking a photo of every sequence of three or more cows, he throws out all of these so-called "lonely" photos, in which there is exactly one Guernsey or exactly one Holstein.

Farmer John Has Recently AcquiredNNnew Cows(3N5105)(3N5105), Each Of Whose Breed Is Either Guernsey Or

Answers

Answer 1
//Note: This program was compiled using turboc compiler. If you are using gcc or any other compiler, then you have to modify the code slightly
#include
#include
int main()
{
int field[110][110]; //FIELD SIZE
int N, i, j;
char dir[50]; //TO REPRESENT THE DIRECTIONS OF 50 COWS
int cow[50][1][2]; //TO STORE THE X,Y COORDINATES OF 50 COWS
int infinity[50]; //TO IDENTIFY, HOW MANY COWS VALUES WILL BE INFINITY AND VICE VERSA
int count[50]; //TO COUNT AMOUNT OF GRASS EATEN BY EVERY COW
int cont = 1; //FLAG VARIABLE, INITIALLY KEEP IT 1.

//CLEAR THE SCREEN
clrscr();

//MARK ALL FIELD POSITIONS AS 1, INDICATING THERE IS GRASS TO EAT
for (i=0; i<110; i++)
for (j=0; j<110; j++)
field[i][j]=1;

//FOR ALL COWS SET INFINITY AS 1 AND COUNT AS 0. I.E WE ASSUME THAT
//EVERY COW WILL EAT INFINITE GRASS AND INITIALLY IT HAS NOT EATEN ANYTHING
//SO COUNT IS SET AS 0
for (i=0 ; i<50 ; i++){
infinity[i] = 1;
count[i] = 0;
}

//READ N, I.E NO. OF COWS
scanf("%d", &N);

//FOR EACH COW, READ THE DIRECTION AND X, Y COORDINATES
for( i=0 ; i fflush(stdin);
scanf("%c%d%d", &dir[i], &cow[i][0][0], &cow[i][0][1]);
}

//REPEAT UNTIL CONT==1
while( cont==1 ){

//FOR EVERY COW CHECK ITS DIRECTION
for( i=0 ; i //IF THE COW IS FACING NORTH DIRECTION
if( dir[i] == 'N'){
//IF THE RESPECTIVE COW'S Y COORDINATE IS LESS THAN 109
if( cow[i][0][1] < 109 )
//IF THERE IS GRASS IN THE PARTICULAR LOCATION,
if( field[cow[i][0][0]][cow[i][0][1]] == 1 ){
//LET THE COW MOVES TO THE NEXT LOCATION, BY INCREMENTING THE VALUE ASSOCIATED WITHN Y-COORDINATE
cow[i][0][1]++;
//INCREMENT THE COUNT VALUE FOR THE RESPECTIVE COW
count[i]++;
}
else
//IF THERE IS NO GRASS IN THAT LOCATION, THEN MAKE THE INFINITY VALUE CORRESPONDING TO THIS COW AS 0
//COW STOPS
infinity[i] = 0;
}

//IF THE COW IS FACING EAST DIRECTION
if( dir[i] == 'E'){
//IF THE RESPECTIVE COW'S X COORDINATE POS IS LESS THAN 109
if( cow[i][0][0] < 109 )
//IF THERE IS GRASS IN THAT PARTICULAR LOCATION
if( field[cow[i][0][0]][cow[i][0][1]] == 1 ){
//LET THE COW MOVE ON TO THE NEXT LOCATION
cow[i][0][0]++;
//INCREMENT THE COUNT FOR THE RESPECTIVE COW
count[i]++;
}
else
//IF THERE IS NO GRASS THEN MAKE INFINTY AS 0 FOR THE PARTICULAR COW.
//THE COW STOPS
infinity[i] = 0;
}
}

/*IN THE PREVIOUS TWO LOOPS WE MADE THE COW TO MOVE TO THE NEXT LOCATION WITHOUT
EATING THE GRASS, BUT ACTUALLY THE COW SHOULD EAT THE GRASS AND MOVE. THE BELOW
LOOP ENSURES THAT. THIS TASK WAS SEPARTED, TO ALLLOW TO TWO COWS TO SHARE THE SAME
POSITION FOR EATING.*/
for( i=0 ; i //IF THE COW IS FACING NORTH
if( dir[i] == 'N'){
//IF CURRENT Y POSITION IS <= 109
if( cow[i][0][1] <= 109 )
//IF IN THE PREVIOUS Y POSITION, THERE IS GRASS
if( field[cow[i][0][0]][cow[i][0][1]-1] == 1 )
//REMOVE (EAT) THE GRASS
field[cow[i][0][0]][cow[i][0][1]-1]=0;
}
//IF THE COW IS FACING EAST
if( dir[i] == 'E'){
//IF CURRENT X POS IS <= 109
if( cow[i][0][0] <= 109 )
//IF IN THE PREVIOUS X POS, THERE IS GRASS
if( field[cow[i][0][0]][cow[i][0][1]] == 1 )
//REMOVE (EAT) THE GRASS
field[cow[i][0][0]-1][cow[i][0][1]]=0;
}
}

/*ASSUME THAT ALL THE COW STOPS EATING AS THERE IS NO GRASS IN THE CURRENT CELL
OR THE COW HAS REACHED THE LAST LOCATION*/
cont = 0;

//REPEAT FOR EVERY COW
for( i=0 ; i //IF THE COW IS FACING NORTH
if( dir[i] == 'N'){
//IF THE COW HAS NOT REACHED LAST Y LOC OR NOT STOPPED EATING
if( cow[i][0][1] < 109 && field[cow[i][0][0]][cow[i][0][1]] !=0 )
cont = 1; //MAKE COUNT AS 1, THE WHILE LOOP SHOULD REPEAT
}
//IF THE COW IS FACING EAST
if( dir[i] == 'E'){
//IF THE COW HAS NOT REACHED LAST X LOC OR NOT STOPPED EATING
if( cow[i][0][0] < 109 && field[cow[i][0][0]][cow[i][0][1]] !=0)
cont = 1; //MAKE COUNT AS 1
}
}
}

//DISPLAY THE OUTPUT
for( i=0 ; i {
//IF THE INFINITY VALUE OF THE RESPECTIVE COW IS 1, THEN DUSPLAY AS INFINITY
if( infinity[i] == 1 )
printf("\nInfinity");
else //ELSE DISPLAY THE RESPECTIVE COUNT VALUE
printf("\n%d", count[i]);
}

getch();
return 0;
}

Related Questions

A _____ is a question about the data structured in a way that the DBMS can recognize and process. a. query b. relationship c. tuple d. product

Answers

Answer:

a

Explanation:

A query is a question about the data structured in a way that the DBMS can recognize and process.

What is relationship in DBMS?

A relationship, in the scope of databases, is known to be a kind of scenario where  two relational database tables and one table is known to have a foreign key that is said to references the primary key.

Note that A query is a question about the data structured in a way that the DBMS can recognize and process.

Learn more about query  from

https://brainly.com/question/2569440

#SPJ2

Wikis are designed for ________, which is allowing people to contribute more than just posting a response

Answers

Answer:

collabirations

Explanation

Wikis are designed for collabirations, which is allowing people to contribute more than just posting a response.

With the goal of keeping your hardware safe, explain the physical hazards you should avoid.

Answers

Based on health safety procedures, the physical hazards you should avoid include "eyestrain."

What are Physical Hazards in Computing?

Physical hazards are computing are hazards that affect the physical body of the users due to operating the Computer system.

Different Physical Hazards in Computing

Back pain Neck and shoulder painsHeadacheEyestrainInjuries of the arms, hands, and thumbs, etc.

Hence, in this case, it is concluded that there are various physical hazards computer users need to avoid.

Learn more about Physical hazards in Computing here: https://brainly.com/question/5622984

You see a whiteboard that has “8-10 years olds, interested in horses” written on it. This is MOST likely a description of:

A.
data management.

B.
target users.

C.
GUI.

D.
iterative development.

Answers

Answer:

B target users

Explanation:

because it targets 8-10 year olds that are interested in horses so it targets that audience range

What are the steps for adding a Watch Window?
Select the cell to watch

Answers

Answer:

How to The Watch Window in Excel

Select the cell you want to watch.

Click the Formulas tab.

Click the Watch Window button. ...

Click the Add Watch. ...

Ensure the correct cell is identified and click Add.

Scroll to the area of the worksheet where you need to add or update values.

Update the cell values.

A company is looking for an employee to install new computers and integrate them into its existing network. Which computer field most likely include this job ?
A. Network systems administrator
B. Information security analysis
C. Computer support
D. Application Development

Answers

A. Network systems administrator

Answer:

A. Network systems administrator

Explanation:

trust me i just did it 1.3.2

when demonstrating 2022 versa’s maneuverability, what available systems should you point out when backing up?

Answers

When demonstrating 2022 Versa's maneuverability, what you should you point out while driving in a parking lot is the excellent rearward visibility that is given or shown by the RearView Monitor.

2022 Nissan Versa is a new model by Nissan. They are known to have different technology and safety features. Its includes  automatic emergency braking with pedestrian detection, remote keyless entry etc.

This vehicle comes with 2 functions such as a 5-speed manual transmission or an Xtronic Continuously Variable Transmission. With this one can quickly adjusts to the best gear ratio for a easyy acceleration and efficiency.

Learn more about 2022 Versa's from

https://brainly.com/question/25980600

A multinational pharmaceutical company used a saffron trident in a promotional campaign for one of its drugs in India. The saffron trident, a religious symbol in India, was meant to indicate the three levels of efficacy of the drug but mistakenly conveyed a religious message to Indians. This miscommunication indicates a problem associated with which step of the international communications process?
i. information source selection
ii. media channel selection
iii. encoding
iv. noise cancellation
v. message transmission

Answers

Answer : Encoding

Explanation : Encoding refers to correctly coding the message so that the receiver gets the clear message without feating any misunderstanding.

Based on the given information, This miscommunication indicates a problem associated with the encoding step of the international communications process. Thus the correct option is 3.

What is communication?

Communication is referred to the exchange of information between two individuals in the form of conversation, opinion, suggestion, or advice with the help of medium or direct interaction.

In the given case, it is explained that during a marketing campaign for one of its medications in India, a multinational pharmaceutical company utilized a saffron trident to represent the drug's three degrees of efficacy.

The method used to transform thoughts into communication is called encoding. The communicator must start decoding in order to communicate meaning in the form of symbols that stand in for concepts or thoughts.

Therefore, option 3 is appropriate.

Learn more about Communication, here:

https://brainly.com/question/22558440

#SPJ6

codes 7.2.8: Listed Greeting python
pls help i have no idea on how to fix this

Answers

The listed greetings program is an illustration of Python functions.

The error in the program is that the program is not properly indented.

Python program uses indents to identify blocks of code.

So, the fix to the program is to properly indent the code, and the fix (without the comments) is as follows:

def greetings(s):

   x = s.split()

   print("Hello, "+x[0]+"! I also enjoy "+x[1]+"!")

Read more about Python programs at:

https://brainly.com/question/16240699

8.3.7: Exclamat!on Po!nts
Write the function exclamation that takes a string and then returns the same string with every lowercase i replaced with an exclamation point. Your function should:

Convert the initial string to a list
Use a for loop to go through your list element by element
Whenever you see a lowercase i, replace it with an exclamation point in the list
Return the stringified version of the list when your for loop is finished
Here’s what an example run of your program might look like:

exclamation("I like music.")
# => I l!ke mus!c.

Answers

The function is an illustration of loops.

Loop instructions are used to repeat operations

The function in Python, where comments are used to explain each line is as follows:

#This defines the function

def exclamation(myStr):

   #This iterates through the string

   for i in range(len(myStr)):

       #This checks if the current character of the string is "i"

       if myStr[i] == "i":

           #If yes, this converts the string to a list

           s = list(myStr)

           #This replaces i with !

           s[i] = '!'

           #This gets the updated string

           myStr = "".join(s)

   #This returns the new string

   return myStr

       

Read more about similar programs at:

https://brainly.com/question/22444309

Does anybody have the answer for 2.19.6 checkerboard for codehs??

Answers

Answer:

speed(0)

penup()

setposition(-200,-200)

pendown()

def draw_square_row():

color_value = 0

for i in range (10):

if color_value %2 == 0:

begin_fill()

color("red")

for i in range (4):

forward(40)

left(90)

forward(40)

color_value = color_value + 1

end_fill()

elif color_value %2 == 1:

begin_fill()

color("black")

for i in range (4):

forward(40)

left(90)

forward(40)

color_value = color_value + 1

end_fill()

def draw_square_row_2():

color_value = 1

for i in range (10):

if color_value %2 == 0:

begin_fill()

color("red")

for i in range (4):

forward(40)

left(90)

forward(40)

color_value = color_value + 1

end_fill()

elif color_value %2 == 1:

begin_fill()

color("black")

for i in range (4):

forward(40)

left(90)

forward(40)

color_value = color_value + 1

end_fill()

def move_up_a_row():

left(90)

forward(40)

right(90)

backward(400)

for i in range (5):

draw_square_row()

move_up_a_row()

draw_square_row_2()

move_up_a_row()

Explanation:

tell me if you get it right

Lucy is in charge of creating a user interface for a new app. During what phase of the project should she expect to complete her work?

A.
alongside the development of the app

B.
after the app has been developed

C.
during the testing phase

D.
during the design phase

Answers

Answer:

C option

Explanation:

Because in testing phase the game has been developed and test for errors in game.

write an algorithm to print circumference of a circle​

Answers

Answer:

1 Start

2 Read the value of radius r of Circle

3. Give Pi = 3.14

4 Calculate area of Circle = Pi x r x r

5. Calculate Circumference of circle

( You can use either C= 2 X Pi X r Or Area (A) = Pi X r X r Circumference (C) = 2 X Pi X r A/r = Pi X r A/r = C/2 So C = 2 x ( A/r ) 5. Print area and Circumference

6. End.

Is this statement true or false? While in slide show mode, if you are not careful you can close the application by clicking the x on the menu bar. True false.

Answers

Considering the Microsoft PowerPoint application, it is False that while in slide show mode, if you are not careful, you can close the application by clicking the X on the menu bar.

Why is it False?

During the slide show of documents whereby the pages of documents are being passed or moved automatically, or by itself, when a user mistakenly or intentionally presses the X on the Menu Bar, the window will ask the user if he wants to save the document before closing.

Slide show in Microsoft PowerPoint is one of the techniques in which a user or Speaker can make a presentation to the audience.

Hence, in this case, it is concluded that the correct answer is False.

Learn more about Microsoft PowerPoint here: https://brainly.com/question/14388120

Answer:

"False"

Explanation:

I took the test!

If your company uses a non-price competition strategy what should you focus on
A. lowering prices
B. differentiation
C. creating direct competitors
D. the public sector

Answers

B- differentiation

nonprice competition strategy refers to strategy to win a business competition that does not involved lowering price of the product.

Businesses mostly do this using differentiation strategy, which is increasing the different variety of product that they sell in the market.

mightier than the waves of the sea is his love for you

Answers

cool but kinda creepy ngl

What is data communication.. ​

Answers

What is data communication?

The exchange of data between source and a receiver by way of transmission media such as a wire cable

Hope this helps you!!

On the following page, write a static method print Short Words that accepts two parameters:_____.
a. a String str containing a list of words (separated by spaces), and an integer maxLength .
b. This method should print out the words in str whose lengths are at most maxLength.
c. You can assume there will always be a space after the last word in the string.

Answers

Methods in Java are collections of program statements that are named, and executed when called/invoked

The printShortWords method in Java where comments are used to explain each line is as follows:

//This defines the static method

public static void printShortWords(String str, int maxLength){

    //This iterates through each word in the string

    for(String word: str.split(" ")){

        //The compares the length of each word to maxLength

        if(word.length()<=maxLength){

            //If the length of the current word is atleast maxLength, the word is printed

        System.out.print(word+" ");

        }

    }

}

Read more about static methods at:

https://brainly.com/question/19360941

Write a program that reads and unspecified number of integers, determines how many positive and negative values have been read, and computes the total and average of the input values (not counting zeroes). The program ends when the user enters 0. The average must be displayed as a floating point. All other values must be displayed as an integer. (For Python)

Answers

Answer:

The program was wrote in the version 3.9.5 of python and it's in the homework.txt file.

One of the best ways to code effective programs is to write so-called _______ programs, using the sequential, selection, or repetition logic structures.

Answers

One of the best ways to code effective programs is to write so-called structured programs, using the sequential, selection, or repetition logic structures.

Structured programs are program types that aim to improve the clarity of program codes to make them readable and reusable.

Structural codes such as the if/then/else for selection and while/for repetition are used to achieve these goals.

So, structured programs are used to write programs that follow the sequential, selection, and repetition logic structures.

Learn more about structured programs here:

https://brainly.com/question/25770844

what is a copy of a theme with different color schemes called?

Answers

Answer:

A copy of a theme with different color schemes is called a Variant

Explanation:

Which of the following describes email nonrepudiation?

A.
the elimination of emails that may contain dangerous viruses

B.
the review of every email sent by the CIA

C.
the use of tracking methods that can identify senders and their locations

D.
the use of encryption methods that ensure senders and their locations cannot be identified

Answers

Answer:

I believe the answer is C, im sorry if im wrong

Need Some Photography help

Answers

C I believe cause that’s what my teacher always told us to do

9. Which of the following is a disadvantage of cloud storage? * Accessibility (offline/without internet) Reduction of storage cost to organization, Increased possibility for disaster recovery, Efficient management of stored Data​

Answers

Answer:

Accessibility offline

Explanation:

Find the error in the following code fragment. int a: System.out.print(a):​

Answers

Answer:

If your using java, then its supposed to be "System.out.print("a")"    

Explanation:

its supposed to have quotations

moving images of real event​

Answers

Answer:

What

Explanation:

While on vacation, Joe receives a phone call from his identity alert service notifying him that two of his accounts have been accessed in the past hour. Earlier in the day, he did connect a laptop to a wireless hotspot at McDonald's and accessed the two accounts in question.
Which of the following is the most likely attack used against Joe?
A. Unauthorized association
B. Honeyspot access point
C. Rogue access point
D. Jamming signal

Answers

The most likely form of cyber attack that was used against Joe during his vacation is: B. Honeyspot access point.

A honeyspot access-point refers to a network system that appears to be legitimate but fraudulent because it is usually set up to capture wireless transmissions, especially by eavesdropping on the sensitive information that are being transmitted by cyber attackers and hackers.

This ultimately implies that, it is usually set up as decoy to lure unsuspecting cyber attackers and hackers, in order to detect, deflect and study their attempt to gain unauthorized access to the network.

In this scenario, a honeyspot access-point was used against Joe during his vacation because he connected to a wireless hotspot at McDonald's.

Read more: https://brainly.com/question/5660386

A ____ is a rectangular object you can click; when you do, its appearance usually changes to look pressed.

Answers

Answer:

button

Explanation:

linnea is researching a type of storage that uses a single storage device to serve files over a network and is relatively inexpensive. what type of storage is linnea researching?

Answers

Considering the situation described above, the type of storage Linnea is researching is "NAS."

What is NAS in storage?

NAS is an acronym for Network Attached Storage. It is used as a file-level computer data storage server attached to a computer network.

NAS is usually applied in serving the files over Ethernet. It is cheaper and can be set up quickly.

Different Components of NAS.

Components of Network Attached Storage include the following:

CPUNetwork Interface CardsOperating SystemNFS and CIFS protocol, etc.

Hence, in this case, it is concluded that the correct answer is NAS

Learn more about NAS here: https://brainly.com/question/25705115

What is the full form of MOS

Answers

Answer:

Military occupational speciality

Other Questions
Which equation is equivalent to -2(2 2x) = 4 8(1 x)? Which figure always has exactly one line of symmetry?A. rectangleB. trapezoidC. isosceles right triangleD. circle scientist who developed a theory of how the universe formed. what is the name of this theory? 8Select the correct answer.Which is NOT a safety guideline for traveling in a car with children?O A. Properly install a car seat and buckle the child inO B. Check behind the car for objects and children before backing outOC. Only play nursery rhymes and similar music in the carODNever use a car seat that has been in an accidentResetNext Name the postulate or theorem you can use to prove the triangles congruent SSSAASASASAS Create union floatingPoint with members float f, double d and long double x. Write a program that inputs values of type float, double and long double and stores the values in union variables of type union floatingPoint. Each union variable should be printed as a float, a double and a long double. Do the values always print correcly? Note The long double result will vary depending on the system (Windows, Linux, MAC) you use. So do not be concern if you are not getting the correct answer. Input must be same for all cases for comparison Enter data for type float:234.567 Breakdown of the element in the union float 234.567001 double 0.00000O long double 0.G0OO00 Breaklo n 1n heX float e000000O double 436a9127 long double 22fde0 Enter data for type double :234.567 Breakdown of the element in the union float -788598326743269380.00OGOO double 234.567000 long double 0.G00000 Breakolon 1n heX float 0 double dd2f1aa0 long double 22fde0 Enter data for type long double: 180 35 X X = ? Which audience is "How to Eat an Ice-Cream Cone" most likely written for? Which of these supreme court cases stated the Constitution gives the federal government certain implied powers?A. Marbury v. MadisonB. McCulloch v. MarylandC. Engel v. VitaleD. Mapp v. Ohio Expand the following(x+2x)(2s-2t)(m-n)(k+9)(4a-3b)(c+6d) I WILL GIVE BRAINLIEST Which of the following is an example of a long-term goal?Developing a lifetime savings plan Eduardo arranged for his employees to acquire the education and tools they need to make decisions on their own. He is now confident that his employees will be able to handle more tasks independently, without extensive managerial assistance. What can be said about Eduardo? Can someone answer this, I'll mark u the brialintest Two divers, G and H, are at depths 20 m and 40 m respectivelybelow the water surface in lake. The pressure on G is P, whilethe pressure on H is P2 if the atmospheric pressure is equivalentto 10 m of water, then the value of P2/P1 is.A. 1.67.B. 2.00.C. 0.50.D. 0.60. For this discussion if you think health care is a human right? Why, or why not? How can equality and inequality in health care impact society? You are making pudding for five friends. The recipe calls for 1/4 cup of sugar per serving. How much sugar do you need? Three yellow balls, two red balls and five orange balls are placed in a bag. Mark draws aball out, and replaces it. He then picks another ball.Draw a tree diagram to represent this information.What is the probability that he gets at least one yellow ball?Give your answer as a fraction in its simplest form Instructions: The impersonal pronoun se is used to express unplanned or accidental events, or to avoid any responsibility. Review the lesson page on "se" and then fill in each blank with the correct form of the verb given.1. caer-to drop, to fallA Juana se le ________sus botellas de agua.2. romper-to breakA mi se me ________ mi bracelete antes de la fiesta.3. olvidar-to forgetA mi se me ________ del examen de algebra.4. romper-to breakA mi mama se le __________sus gafas de sol.5. daar-to damageA ellos se le __________ sus libros en la lluvia.6. perder (e:ie)-to loseA ti se te __________ tus amigos en el festival. Which signal word shows cause?as a resultthis led tothereforesince