Write a PHP program to find heights of the top three building in descending order from eight given buildings.
Input:0 ≤ height of building (integer) ≤ 10,000
Pictorial Presentation:
<?php $heights = array(); while($line = fgets(STDIN)) { rtrim($line, "\n"); array_push($heights, (int)$line); } rsort($heights); print("Heights of the top three buildings:\n"); echo $heights[0]."\n"; echo $heights[1]."\n"; echo $heights[2]."\n"; ?>
Sample Output:
Heights of the top three buildings: 45 25 24
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer