Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with this please, Write a C program with the following specs. Requirements Output samples . Details Failfish are small monsters that eat only

Need help with this please, Write a C program with the following specs.

image text in transcribed

image text in transcribed

Requirements

image text in transcribed

Output samples

image text in transcribed.

Details Failfish are small monsters that eat only other Failfish. This makes them ecologically and practically useless, causing many small monster scholars to wonder how they ever came to exist in the first place. They are delicious, which is a plus, but since they eat each other, they're almost impossible to farm. That doesn't keep people from trying. It keeps them from succeeding, but not from trying. You have been hired by an ambitious small monster farmer to record their attempts to farm Failfish. The farmer has: Ten Failfish ponds arranged one after the other. Each pond has a name, and also a sequence number from 1 to 10. G groups of Failfish that they've captured. Groups of Failfish are called Failgroups. They were called Failschools once, but small monster scholars determined that Failfish are unable to learn. Each Failgroup g: has n; Failfish in it with n: 22. Note that i is the pond number - the Failfish don't have to be in ponds 1..G. Each Failfish in a Failgroup is branded with a sequence number, from 1 to ni. (Modern small monster farming methods being humane, the branding is done with a particularly waterproof marker. No Failfish are harmed during modern Failfish farming. (Except when they get eaten.)) The Meal, First Course: Failfish in a Failgroup form a Failcircle when preparing to eat each other. For a Fish 7 Fish 1 group of seven Failfish, the Failcircle looks like Figure 1. Once a Failcircle is formed, phase 1 of the dining begins. It's controlled by three values: , the eating counter; th, the minimum Failgroup threshold; Fish 6 and ne, the number of Failfish. The Failfish begin counting with the smallest-numbered Failfish in the Failcircle. Fish 5 The Failfish skip the first e - 1 Failfish, and eat the oth Failfish clockwise of the starting Failfish. Fish 4 The Failfish then skip the next e; - 1 fish, and eat the eth Failfish clockwise of the last-eaten Failfish. Figure 1: A typical Faileirele. This process continues until the Failcircle's population drops to thi, the minimum Failgroup threshold Each Failgroup dines independently according to this algorithm. No one is quite sure why. The fish will continue to eat each other until the population of the group is reduced to a threshold value thi. Uneaten fish at this point continue to the second course. Fish 2 Fish 3 The Meal, Second Course: At this point the Failcircles unwind into Falqueues, with the smallest-numbered Failfish from each Failcircle at the head of that Failcircle's Failqueue. The Failfish converge on and consume the highest-numbered Failfish of those at the heads of the queues. In case of a tie, the Failfish at the head of the smallest-numbered Failgroup's queue is eaten. This continues until there is only one Failfish remaining. You are to report which Failfish this is, based on the theory that this information will allow the farmer to breed Failfish that are less likely to be eaten. (it will not.) Input and Output Read input from cop3502-as2-input.txt. Write output to cop3502-as2-output--.txt. For example, my output file will be named cop3502-as2-output-gerber-matthew.txt. There are blank lines in the sample inputs to make them more readable. They may or may not be present in the actual inputs; you should completely ignore blank lines. The first line of the input file contains the number of Failgroups. Each line after that contains, separated by spaces: The pond number 9 A name for the pond The value n; (2 Sn: -.txt. For example, my output file will be named cop3502-as2-output-gerber-matthew.txt. There are blank lines in the sample inputs to make them more readable. They may or may not be present in the actual inputs; you should completely ignore blank lines. The first line of the input file contains the number of Failgroups. Each line after that contains, separated by spaces: The pond number 9 A name for the pond The value n; (2 Sn:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions