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

what actions can be performed via voice commands using 2022 versa’s siri® eyes free?

Answers

The actions that can be performed via voice commands using 2022 versa's siri® eyes free are;

- Send and receive text messages

- Make and receive calls

- Select and play music

2022 versa's siri® eyes free is a media feature that can be connected to your iPhone in the latest car by Nissan called Nissan 2022 versa.

Now Siri® Eyes Free Available functions include:

Making and receiving callsSending and reading text messagesSelecting and playing musicReading notificationsRequesting directions or other

This Siri® Eyes Free is usually located on the steering wheel and the way to operate it is by;

Press THIS button on the steering wheelSpeak a command.Wait for Siri® Eyes Free to reply. Within 5 seconds, press THIS button on the steering wheel to reply or give another command.

Read more on cars at; https://brainly.com/question/25981194

to find detailed information about the origin of an email message, look at the ________________.

Answers

Email header. The email header is a code snippet in an HTML email, that contains information about the sender, recipient, email's route to get to the inbox and various authentication details

in python:
The mode of a list of numbers is the number listed most often. The median of a list of numbers is the value in the middle of the list if the list is arranged in order. For this software solution you will do the following:

Take 10 numbers as input from the user and display the number with the highest mode. If there is a tie, you will need to show all of those numbers.
Your program must create a user-defined function that takes an array of numbers as a parameter and returns the value that appears the most often in the array.
For those same 10 numbers your program must create a user-defined function that takes an array of numbers as a parameter and returns the value which is the median for those numbers.

please help!

Answers

Python can be used to implement central of tendencies such as mean, median and mode using the statistic module

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

#This imports the statistics module

import statistics

#This defines the function that calculates the mode

def calcMode(myList):

   #This prints the mode

   print(statistics.multimode(myList))

#This defines the function that calculates the median

def calcMedian(myList):

   #This prints the median

   print(statistics.median(myList))

#The main method begins here

#This initializes the list

myList = []

#The following iteration gets input for the list

for i in range(10):

   myList.append(int(input()))

#This calls the calcMode method

calcMode(myList)

#This calls the calcMedian method

calcMedian(myList)

Read more about similar programs at:

https://brainly.com/question/25026386

A restaurant recorded the ages of customers on two separate days. You are going to write a program to compare the number of customers in their forties (ages 40 to 49).

What is the missing line of code?

customerAges = [33, 23, 11, 44, 35, 25, 35, 68, 51]

count40s = 0
for item in customerAges:
_____;
count40s = count40s + 1
print("Forties:", count40s)


if 40 > item > 49

if 40 < item < 49

if 40 <= item <= 49:

if 40 >= item >= 49

Answers

Answer:

if 40>= item >=49

Explanation:

what computer is designed for particular application​

Answers

Answer: Applications for desktop or laptop computers are sometimes called desktop applications, while those for mobile devices are called mobile apps. When you open an application, it runs inside the operating system until you close it

Explanation:

how to send an email without showing recipients outlook

Answers

Answer:

Outlook. When you open a new blank email in Outlook, click on the “Options” tab. From there, you'll want to select the Bcc field in the message header. This is your “blind carbon copy” option, meaning that your email recipients will not see other names on the list.

Explanation:

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

Do you want to run a listing to see files that were used by the last access date is date does not display by default which command would you use to find additional properties of the files to reference.

Answers

Considering the situation and the computer application, the command you would use to find additional properties of the files to reference is "Get-childitem | get-member "

What is Get-childitem command?

Get-childitem command in computer applications is used to get the items in specific locations.

Get-childitem command can be used to gets the items inside a file container, usually referred to as child items.

Similarly, the Get-member command used to gets the members, the properties, and methods of files.

Hence, in this case, it is concluded that the correct answer is Get-childitem | get-member

Learn more about Computer commands here: https://brainly.com/question/25243683

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 does the Finder do?


locates files

organizes computer folders and files

opens applications

empties the Trash

deletes files

turns off the computer

Answers

locate files , open applications

A small network that consists of devices connected by Bluetooth, such as a smartphone and a computer, is referred to as a ________.

Answers

Answer:

I think is technologies

Tom is not sure how to code contents such as title and meta elements. These are coded as ____ elements.

Answers

Answer:

Tom is not sure how to code contents such as title and meta elements. These are coded as head elements.

Hope that helps. x

Answer:

head elements

Explanation:

answer is above

Can someone please help

Answers

Answer:

Explanation:

la reponse est le premier et le 3 eme pointcar en effet le premier point c est logiqye e le 2 e aussi  

Additional Activities Direction: List down all the safety and work procedures in using newly purchased gadget. Write your answers on a separate sheet of paper.​

Answers

Answer: Keep your phone away from your body and head. Turn off your phone or turn on airplane mode at bedtime. Use headsets, preferably air tube, and speaker phone when possible. Don't carry your cell phone in your bra, shirt, or front pants pocket, especially if you're pregnant.

Explanation:

write a program to print. *
**
***
****
*****​

Answers

Program:-

[tex]\tt for\:i \:in\: range(2,6):[/tex]

[tex]\tt\quad for\: j\: in \:range(1,i+1):[/tex]

[tex]\tt\quad\quad print("*",end='')[/tex]

[tex]\tt\quad print()[/tex]

Output:-

[tex]\tt **[/tex]

[tex]\tt ***[/tex]

[tex]\tt ****[/tex]

[tex]\tt *****[/tex]

A _____ is a network operating on a radio frequency (RF), consisting of radio cells, each served by a fixed transmitter.

Answers

Answer:

A cellular network is a network...

You are creating a program that can add up the amount of money the user spent that day. Right down to the penny! What kind of variables should you create? a default variable a user variable an integer variable a float variable

Answers

Answer:A. A default Variable

Explanation:

Answer:

A

Explanation:

Did it on a Test

Which of the following applies to a trademark?
o belongs to just one company or organization
O always shown on the outside of a garment
O a way for people to copy a pattern
0 a mark that represents a product's "sold"
status

Answers

Answer:

a

Explanation:

Answer:

belongs to just one company or organization

Explanation:

edge 2021

hiiiiiiiiihwdawdfgthnythgrfergthyjuhgfd

Answers

Answer:

Your answer would be gas.

Explanation:

Steam is just water just evaporated.

no i will not marry u

In cell a10 enter a formula using or to display true if net profit before tax in 2019 (cell b5) are greater than 750000(seven hundred, fifty thousand) or net profit before tax in 2020 (cell c5) are greater than 750000 (seven hundred, fifty thousand). use cell references where appropriate and enter the arguments exactly as described in this question.

Answers

The OR Excel function is a function that is used to test several conditions in one statement.

The Excel formula to display true based on the conditions in cell A10 is =OR(B5>750000,C5>750000)

From the question, we have:

Cell B5 represents the net profit before tax in 2019Cell C5 represents the net profit before tax in 2020

The syntax of the OR logical function is: =OR([conditions])

So, the Excel formula to display true based on the conditions in cell A10 is =OR(B5>750000,C5>750000)

Read more about Excel formulas at:

https://brainly.com/question/14820723

In an attempt to reach an all-time record for its premier, ads for the highly anticipated Avengers: Endgame are run on all the major networks and cable stations across the country from 8:00 p.m. to 10:00 p.m., or during ________ time.

Answers

Based on the contextual situation, the cable stations across the country from 8:00 p.m. to 10:00 p.m., or during Late-fringe time.

What is Late-Fringe Time?

Late Fringe time is a term used in television that describes the television hours that follow the prime time.

Generally, the prime period is usually between 8:00 p.m. to 10:00 p.m., while the Late Fringe time is around 11 p.m. to 1 a.m.

Hence, in this case, it is concluded that the correct answer is "Late-Fringe period."

Learn more about Television hours here: https://brainly.com/question/1006994

Which of these would make text on a slide difficult to read?
Ohigh contrast between text and background
Olow contrast between text and background
O a sans serif font
O a large font when the presentation is in a large room

Answers

Low contrast between your text and the background

What number is represented as a binary code of 101110

Answers

Answer:

46 i think

Explanation:

sorry if thats wrong

46

46 in binary is 101110

You can protect yourself from identity theft by using ____ when transmitting information over network connections. a. cookies b. port-scanning c. biometrics d. encryption

Answers

Answer:

D

Explanation:

Encryption secures transmissions on the internet to or from your PC

which of the following is a true statement?

A. in the customary system measurements are often expressed as decimals.

B. in the metric system measurements are often expressed as fractions.

C. in the customary system measurements are often expressed as fractions.

D. fractions are equally common in both the metric and customary systems.​

Answers

Answer:

C

Explanation:

yeah-ya........ right?

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.

In 1956, the unit byte was coined by American statistician and computer scientist John Tukey
True or False (Give Explanation)​

Answers

Answer:

False

Explanation:

John Wilder Tukey was an American mathematician and statistician, best known for the development of the Fast Fourier Transform (FFT) algorithm and box plot. The Tukey range test, the Tukey lambda distribution, the Tukey test of additivity, and the Teichmüller–Tukey lemma all bear his name. He is also credited with coining the term 'bit' and the first published use of the word software.

To gain access to the functions and variables of a library module, use a(n) _________ statement. A. import B. export C. global D. library

Answers

Answer: import

Explanation:

List three (3) features of first generation computer
PLEASE HELP!!!!!

Answers


Features of first generation computers:

Technology used: vacuum tube.

Machines languages were used to instruct the computer.

Magnetic core memory was used as primary memory.

Electrostatic tubes, Parer tape, punch card, magnetic tape.

PLEASE I NEED HELP ASAP PLEASE PLEASE!!!

For a list of numbers entered by the user and terminated by 0, find the sum of the positive numbers and the sum of the negative numbers. C++ language only.

Answers

Answer:

Following are the program in the Python Programming Language

#set variables to 0

positive_sum=0  

negative_sum=0  

#print message  

print("Enter 0 to terminate")  

#set the while loop  

while(True):  

#get input from the user  

num=float(input("Enter positive or negative numbers: "))  

#set if statement to check condition  

if(num==0):  

  break  

elif(num>0):  

  positive_sum+=num  

else:  

  negative_sum+=num  

#print output with message  

print()  

print("sum of positive numbers: ", positive_sum)  

print("sum of negative numbers: ", negative_sum)  

Output:  

Enter 0 to terminate  

Enter positive or negative numbers: 1  

Enter positive or negative numbers: 3  

Enter positive or negative numbers: 5  

Enter positive or negative numbers: -7  

Enter positive or negative numbers: -2Enter positive or negative numbers: 0  

sum of positive numbers:  9.0  

sum of negative numbers:  -9.0

Explanation:

Here, we set two integer data type variables "positive_sum", "negative_sum" and initialize to 0.

Then, we set the while infinite loop inside the loop.

Set a variable "num" and get input from the user in it.

Set the if conditional statement and check condition the variable "num" is equal to 0 then, loop will terminate.

Set the elif statement and check condition the variable "num" is greater than 0 then, add that input and store in the variable "positive_sum"

Otherwise, add that input and store in the variable "negative_sum".

Finally, we print the output with the message.

Other Questions
two functions are shown below.f(x)=4^x-62g(x)=x^2-2x+5evaluate g(-2)+f(3) what name was given to the head of government during colonial rule?(a) prime minister (b) premier(c) President (d) governor What do u chooseeat the red pill be ueat the blue pill be u 2 Annette measured pepper plant sprouts and recorded the following lengths ininches:1/3 .0.75, 1/4 .0.5If Annette ordered the lengths from least to greatest, which one would comesecond?Answer pls Hey yall pls help me ASAP :) pythagorean theorem to find the length of the hypotenuse in the triangle 16 30 Simplify the expression3+410 8 weakness : no separate executive branch explain in your own words "no separation executive branch" (answer this)predict why this weakness might be a problem (answer this) A man is 5 feet 9 inches tall. To find the height of a tree, the shadow of the man and the shadow ofthe tree were measured. Thelength of the man's shadow was 3 feet 6 inches. The length of the tree's shadow was 10 feet6 inches. What is the height ofthe tree? What benefits does TV bring about to people is life ? After a nuclear disruption in Siberia during the winter, scientists found evidence that the DNA in cells of local wildlife newboms had several mutations. Which ofthe following is a valid claim that can be made about how the nuclear disruption led to mutations?A High temperatures during the disruption caused damage to parental gametes (sex cells) resulting in mutations in newbornsmutations in newbornsB. High temperatures during the disruption caused damage to parental somatic cells resulting. C Exposure to radiation during the disruption caused damage to parental gametes (sex cells) resulting in mutations in newborns.D. Exposure to radiation during the disruption caused damage to parental somatic cells resulting in mutations in newborns. help me quickly please!!if AC= 143BC= 8x+4AB= 7x+4find BC. WILL GIVE BRAINLIEST LIKE FIVE HEARTS THE WHOLE SHEBANGThe graph shows how many bottles a machine caps in a certain number of seconds.Part AWhat is the constant of proportionality, and what does it mean in this situation?Use the drop-down menus to show and explain your answer.The constant of proportionality isChoose... (Either 15, 20, or 30); the machine caps(20)bottles inChoose... (either one second, 15 seconds, or 1 minute) Please graph as this coordinate plane is. Thank you 14.) Which numbers are in order from least to greatest?O 79%, 0.55, 1/4O 1/4, 0.55, 79% 0.55, 1/4, 79%O 79%, 1/4,0.55 complete the sentence when the bell was ringing, the teacher................ Who won the Garcia v United States case ? This kind of engineer draws onmechanical, applications,electronic, test and programengineering. Design challengesinclude emissions laws, sharedplatforms, performance andconsumer demands. plot (-7,0) on a graph solve the equation 5-x=8