How to resolve the algorithm Stem-and-leaf plot step by step in the Icon and Unicon programming language
How to resolve the algorithm Stem-and-leaf plot step by step in the Icon and Unicon programming language
Table of Contents
Problem Statement
Create a well-formatted stem-and-leaf plot from the following data set, where the leaves are the last digits: The primary intent of this task is the presentation of information. It is acceptable to hardcode the data set or characteristics of it (such as what the stems are) in the example, insofar as it is impractical to make the example generic to any data set. For example, in a computation-less language like HTML the data set may be entirely prearranged within the example; the interesting characteristics are how the proper visual formatting is arranged. If possible, the output should not be a bitmap image. Monospaced plain text is acceptable, but do better if you can. It may be a window, i.e. not a file.
Note: If you wish to try multiple data sets, you might try this generator.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Stem-and-leaf plot step by step in the Icon and Unicon programming language
Source code in the icon programming language
procedure main(A)
prune := integer(\A[1]) | 10 # Boundary between leaf and stem
every put(data := [], integer(!&input))
writes(right(oldStem := 0,5)," |")
every item := !sort(data) do {
leaf := item % prune
stem := item / prune
while (oldStem < stem) do writes("\n",right(oldStem +:= 1, 5)," |")
writes(" ",right(leaf,*prune-1,"0"))
}
write()
end
You may also check:How to resolve the algorithm DNS query step by step in the TXR programming language
You may also check:How to resolve the algorithm Erdős-Nicolas numbers step by step in the J programming language
You may also check:How to resolve the algorithm Fast Fourier transform step by step in the Klong programming language
You may also check:How to resolve the algorithm Check that file exists step by step in the Lasso programming language
You may also check:How to resolve the algorithm Safe addition step by step in the REXX programming language