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

Write true or false:-
1. The start attribute always accept an integer value.
2. Description list is used to create a bulleted list.
3. The <DT> tag is used to create a table in HTML.
4. The <TR> tag is used to create cells in the table.
5. The VALIGN in attitude of the <TD> tag is used to Align the position of text in the cell vertically.

And please don't give only one answer, if you are giving, then please give all the answers. ​

Answers

Answer:

false

true

false

true

false

Explanation:

.

congress are smart becuase.....

Answers

Answer:

If we are talking about government then they are smart bc of there two house policies, both are equal yet super unique. They make sure each state has an equal voice in the senate.

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.

Brake fluid is made up of a chemical that:​

Answers

hi there!

Brake fluid is a type of hydraulic fluid used in hydraulic brake and hydraulic clutch applications in automobiles, motorcycles, light trucks, and some bicycles. It is used to transfer force into pressure, and to amplify braking force. It works because liquids are not appreciably compressible.

hope this helps.

________ is a function pertaining to a particular database that develops procedures and practices to control and protect the database.

Answers

Answer: Database administration

Explanation:

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

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]

What software type is software that is distributed free of charge, but the source code is not available

Answers

Answer:

Closed Source software programs

Please help explain Loops question. I will give brainliest.

Answers

Answer:

And 1 and 2 and 3

Explanation:

It is asked to display the 'and' every time, and the count is equal to 1 plus the previous count starting at zero, so it runs 3 times

Katie is writing a print statement but nothing is printing. Which of the following should she check for?

A.
Make sure the print statement is surrounded by parentheses.

B.
Make sure the word print is in all capital letters.

C.
Make sure there is a colon after the print statement.

D.
Make sure the next line after the print statement is indented.

Answers

Answer:

A.

Explanation:

Parenthesis are required to be around the data in a print function. All the letters in a  print statement should be lowercase. A colon isn't required after a print statement. Indentation is not needed for a print statement because there are no colons after the statement instead. Here's an example where you would need to indent the line:

def randNum( x, y ):

    x = input("Enter number: ")

    y = input("Enter number: ")

    return x * y

Here's an example of a print statement:

print("My name is Sullen.")

Write a program that outputs "Hello World!".

Answers

print(“Hello World!”)

I hope this helps :) I’m sry is this what you wanted or were you looking for something else because I’m willing to help either way.

Megan owns a small neighborhood coffee shop, and she has fifteen employees who work as baristas. All of the employees have the same hourly pay rate. Megan has asked you to design a program that will allow her to enter the number of hours worked by each employee and then display the amounts of all the employees’ gross pay. You determine that the program should perform the following steps:

1. The text that is in the file is stored as one sentence. Incorporate the code that reads the file’s contents and calculates the following:
a. total number of words in the file
b. total average number of words per sentence
c. total number of characters in the file
d. total average number of characters per sentence


file name: employee_names.txt
file text:
George Thomas
Melinda Harris
Norah Jeddery
Jorge Ortiz
Samantha Gregory
Tanvi Gupta
William Edwards
Tania Gomez
Erica Sanders
Gracie Lou Freebush
Tony Montana
Obi-Wan Kenobi
Cruella De Vil
Marty McFly
Napoleon Dynamite

Answers

Answer:

she gives 10 dollars an hour

Explanation:

no

Fill in the blank: Every database has its own formatting, which can cause the data to seem inconsistent. Data analysts use the _____ tool to create a clean and consistent visual appearance for their spreadsheets.

Answers

The tool used by data analysts to create a clean and consistent visual appearance for their spreadsheets is called clear formats.

A database refers to an organized or structured collection of data that is typically stored on a computer system and it can be accessed in various ways. Also, each database has a unique formatting and this may result in data inconsistency.

In Computer science, a clean data is essential in obtaining the following:

Data consistencyData integrityReliable solutions and decisions.

Furthermore, spreadsheets are designed and developed with all kinds of tools that can be used to produce a clean data that are consistent and reliable for analysis.

In this context, clear formats is a kind of tool that is used by data analysts to create a clean and consistent visual appearance for their spreadsheets.

Read more on database here: https://brainly.com/question/15334693

Write a program which will -

• Enter the score the student got in the test.
• Enter the maximum number of marks for the test.
• Divide the score by the maximum to work out the percentage.
• Check to see if the percentage is greater than 52. If it is then say "well done you have at least a grade 5"
• If the percentage is less than 52 then display "Unlucky, you need to revise more for the next test."
Will give out brainliest :)

Answers

Answer:

down below

Explanation:

score = input() # gets student's score input

max = input() # gets max number

percent = (score/max)*100 # multiply by a hundred to get percentage

if percent > 52: # checks if percent is greater than 52

  print("well dont you have at least a grade 5")

else # if percent is less than or equal to 52 it will print this instead

  print("Unlucky, you need to revise more for the next test.")

THIS PART IS NOT CODE:

make sure you indent/tab the print statements or else you'll get an error

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

Answers

Answer: header

Explanation:

What are two characteristics of switches? (Choose two.) * 1 point A. Switches identify the intended destination of the data that they receive B. Switches cause more data collisions than hubs b C. Switches are capable of sending and receiving data at the same time D. Switches send each packet to all of the computer that are connected to them.​

Answers

Answer:

A. Switches identify the intended destination of the data that they receive. And C. Switches are capable of sending and receiving data at the same time

Explanation:

Switches can be used as inputs (Analog), or outputs (digital). These inputs and outputs are signals that the switches send or receive- Or at least as push button switches... But the same applies to network switches.

Hope this helps! Have a great day!

The Internet Assigned Numbers Authority (IANA) delegates Internet resources to the Regional Internet Registries (RIRs) who then:

Answers

Answer:

management, distribution, and registration of public IP addresses within their respective assigned regions.

can’t be opened because apple cannot check it for malicious software.

Answers

Answer:

try to reset  your computer.

Explanation:

Sidney needs to create a decimal number variable that will be added to another number. What kind of variable is required?binaryBooleanstringfloat

Answers

Answer:

Option D. float is the correct answer.

Explanation:
Decimal number contains decimal point. Out of all the given data types, float data type store the number with decimal point.
As the number has to be further used for calculations float ahs to be used. Because the numbers can also be stored in string but cannot be used for further calculations.

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

The temperature at 8 AM was 44°F and at noon it was 64°F. what was the percent of change from 8 AM to noon?

Answers

Answer: 45.45%

Explanation:

Time Passed: 4 hours

Difference in Temperature: 20°F

20/44 = .45454545454545

.45454545454545*100 = 45.45%

Correct me if I am incorrect.

If you know that a file for which you are searching starts with the letters MSP, you can type ____ as the search term.

Answers

Map I think it is the answer

Pomelo and Calamansi Trees are type of plants that suitable in this method.A. Cleft-Grafting B. Marcotting C. Layering D. T-Budding

Answers

Pomelo and Calamansi Trees are type of plants that suitable in this method.A. Cleft-Grafting

Understanding that protection of sensitive unclassified information is:

Answers

Answer:

Not necessarily malignant

Explanation:

As the word "unclassified" shows it's not damaging, however I still doesn't recommend if it's not necessary.

Fill in the blank to complete the sentence.
Binary Digit 1 0 0 0 0 0 1 1
Decimal Equivalent of Place Value 128 ? 32 16 8 4 2 1
The missing place value is
.

Answers

Answer:

ANSWER:62

Explanation:i dont know just trust me

The base of every positional numeral system is ten, which is expressed as 10 in the decimal numeral system (also known as base-ten). It is the numeral system that modern cultures utilize the most frequently.

What Binary Digit Decimal Equivalent of Place Value?

In binary numbers, place values rise by a factor of 2, as opposed to decimal numbers, where place values rise by factors of ten. The symbol for a binary number is X2. Think about the binary number, 10112 as an example. The place value of the rightmost digit is 120, while the place value of the leftmost digit is 123.

Digits are used to fill in the spaces on the place value chart in the decimal system. Binary, on the other hand, is restricted to 0 and 1, therefore we can only utilize 0 or 1 with each location. In a binary place value chart, the binary number 1001 is positioned to the right.

Therefore, Decimal Equivalent of Place Value 128 64 32 16 8 4 2 1.

Learn more about Binary Digit here:

https://brainly.com/question/20849670

#SPJ2


Pls help me pls I’m struggling

Answers

you have it correct

create a parameter query where the user will enter a value to use as the criterion

Answers

Click in the Criteria row in the InsuranceType column and type [Enter Insurance Type]. Click the Run button. Type dental when prompted. Click OK.

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:

susan wrote the recursive formula for the sequence represented by the exploit formula An=3+2n. put an C net to any correct statements are correct her error

Answers

The recursive formula of the explicit formula [tex]A_n = 3 + 2n[/tex] is [tex]A_n = A_{n-1} + 2[/tex]

The explicit formula is given as:

[tex]A_n = 3 + 2n[/tex]

When n = 1, we have:

[tex]A_1 = 3 + 2(1)[/tex]

[tex]A_1 = 5[/tex]

When n = 2, we have:

[tex]A_2 = 3 + 2(2)[/tex]

[tex]A_2 = 7[/tex]

When n = 3, we have:

[tex]A_3 = 3 + 2(3)[/tex]

[tex]A_3 = 9[/tex]

So, we have:

[tex]A_1 = 5[/tex]

[tex]A_2 = 7[/tex]

[tex]A_3 = 9[/tex]

Rewrite the functions as follows:

[tex]A_1 = 5[/tex]

[tex]A_2 = 5 + 2[/tex]

[tex]A_3 = 7 + 2[/tex]

So, we have:

[tex]A_1 = 5[/tex]

[tex]A_2 = A_1 + 2[/tex]

[tex]A_3 = A_2 + 2[/tex]

Express 2 as 3 - 1

[tex]A_3 = A_{3-1} + 2\\[/tex]

Substitute n for 3

[tex]A_n = A_{n-1} + 2[/tex]

Hence, the recursive formula is [tex]A_n = A_{n-1} + 2[/tex]

Read more about recursive and explicit formulas at:

https://brainly.com/question/11235928

lenny joggy along a trail for 1.35 hours he ran at a pace of 3.2 miles per hour. how far did lenny jog?

Answers

Answer:

Lenny jogged along a trail for 1.35 hours. He ran at a pace of 3.2 miles per hour. How far did Lenny jog? Answer Lenny jogged 4.32 miles.

Explanation:

Other Questions
please help me !!! omaths student see the attached question The travelers, with their translators, (visit, visits) the museum PLS HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Skeletal muscle is the muscle you can control and move. Where would you find skeletal muscle in your body?A. brainB. handC. heart Victor has put 1000 hours into playing an online video game he has paid 671.34 over the course of the entire game how much did much did he pay per hour played? !!SOMEBODY PLEASE HELP ME OUT!!What is the slope of the line?? Combine like terms to create an equivalent expression.-2.5(4x3) Can someone help me with my living earth homework The muscular system is responsible for all of the following EXCEPT: Madelynn makes the following statement: "Since I have 28 people that I defi-nitely want to invite to my party, I might as well choose Party B and invite evenmore people."Was Madelynn correct to go with Party B and invite more people? Explain why orwhy not. What is the primary responsibility of United States Attorneys?to assist the District Attorneyto prosecute cases against federal employeesprosecute cases on behalf of the federal governmentto establish a good defense for the accused Keeven uses 78 feet of fence to make a rectangle pan for his pet rabbit. The length of the pin is 20 feet.What is the width of the rectangle pen Select the correct answer.Which equation best models the set of data shown in this table?0246008101214161811192735374044454852OA. y = 11v 0.3 + 4.3OB.y = 1177 + 0.3 4.3O c.y = 23 + 17OD. y = 2.3 17 what is meant by chewing the cub? Francis owns a cake shop. She is currently preparing cupcakes (x) and cookies (y) for two birthdayparties. The first birthday party ordered 20 cupcakes and 40 cookies and their total cost was $61. The second birthday party ordered 30 cupcakes and 30 cookies. Their total cost was $64.50. PLS HELP round to the nearest hundredth Which of the following minerals are NOT felsic?**quartzfeldsparolivinemuscovite what feelings and emotions do you think kipling was trying to inspire american in this poem simplify 10^9 divided by 10^7 Because many students try to maintain a healthy diet, Alma wants part of her paper to address students who wantto include more nutrients in their diet. Which fact from her list should she make sure to include in her paper?OA. Chocolate contains small amounts of caffeine..Chocolate can be expensive.OC.Chocolate contains many antioxidants.