Computer Science

Babbling Brooks
A series of streams run down the side of a mountain. The mountainside is very rocky so
the streams split and rejoin many times. At the foot of the mountain, several streams
emerge as rivers. Your job is to compute how much water flows in each river.
At any given elevation there are n streams, labelled 1 to n from left-to-right. As we
proceed down the mountainside, one of the streams may split into a left fork and a right
fork, increasing the total number of streams by 1, or two streams may rejoin, reducing the
total number of streams by 1. After a split or a rejoining occurs, the streams are
renumbered consecutively from left-to-right. There is always at least one stream and
there are never more than 100 streams.
The first line of input contains n, the initial number of streams at some high altitude. The
next n lines give the flow in each of the streams from left-to-right. Proceeding down the
mountainside, several split or rejoin locations are encountered. For each split location,
there will be three lines of input;
a line containing 99 (to indicate a split)
a line containing the number of the stream that is split
a line containing a number between 0 and 100, the percentage of flow from the split
stream that flows to the left fork. (The rest flows to the right fork).
For each join location, there will be two lines of input;
a line containing 88 (to indicate a join)
a line containing the number of the stream that is rejoined with the stream to its right
The flow from both joined streams is combined. After the last split or join location will
a single line containing 77 (to indicate end of input)
Your job is to determine how many streams emerge at the foot of the mountain and what
the flow is in each. Your output is a sequence of real numbers, rounded to the nearest
integer, giving the flow in rivers 1 through n.
Sample Input (Input file :
Output for Sample Input (Output file : brooks.out)
5 55
can you help me with this one...i don't understand it.

  1. 👍 0
  2. 👎 0
  3. 👁 331

Respond to this Question

First Name

Your Response

Similar Questions

  1. trig

    A survey team is trying to estimate the height of a mountain above a level plain. From one point on the plain, they observe that the angle of elevation to the top of the mountain is 24. From a point 1000 feet closer to the

  2. PreCal

    Angel of Elevation: You are skiing down a mountain with a vertical height of 1500 feet. The distance from the top of the mountain to the base is 3000 feet. What is the angle of elevation from the base to the top of the mountain?

  3. Honors Pre-Calculus

    You are traveling in a car toward a certain mountain at a speed of 80km/hr. The apparent size of the mountain is .5degrees. Fifteen minutes later the same mountain has an apparent size of 1 degree. About how tall is the mountain?

  4. Physics

    A circular track has several concentric rings where people can run at their leisure. Phil runs on the outermost track with radius rP while Annie runs on an inner track with radius rA = 0.90 rP. The runners start side by side,

  1. MATH!!!

    Suppose that a person with a reach of 27 inches and a shoulder height of 5 feet is standing upright on a mountainside that makes a 62 degrees angle with the horizontal..Can the person touch the mountain?

  2. Physical Geography

    Will someone please check my work? I cannot seem to post the map that is in the workbook. Assume that a parcel of air is forcd to rise up and over a 4000 meter high mountain.The initial temp of the parcel at sea level is 30*c, and

  3. Triganometry

    To measure a stone face carved on the side of a mountain, two sightings 407 feet from the base of the mountain are taken. If the angle of elevation to the bottom of the face is 36 degrees and the angle of elevation to the top of

  4. Math

    Consider the following series: 1,2,3,4,5,10,20,40....which starts as an arithmetic series? ...but after the first five terms becomes a geometric series. Prove that any positive integer can be written as a sum of distinct numbers

  1. physics

    To start an avalanche on a mountain slope, an artillery shell is fired with an initial velocity of 340 m/s at 45.0° above the horizontal. It explodes on the mountainside 41.0 s after firing. What are the x and y coordinates of

  2. Physical Geography

    Assume that a parcel of air is forced to rise up and over a 6000-foot-high mountain. The initial temperature of the parcel at sea level is 76.5°F, and the lifting condensation level (LCL) of the parcel is 3000 feet. The DAR is

  3. Math

    a surveyor is 3 miles from a mountain. The angle of elevation from the ground to the top of the mountain is 15 degrees. What is the height of the mountain?

  4. math

    A power station is on one side of a river that is 3/4 mile wide, and a factory is 8 miles downstream on the other side of the river. It costs $24 per foot to run power lines over land and $30 per foot to run them under water.(1

You can view more similar questions or ask a new question.