Write a program that reads from std-in two numbers A and B and writes
to std-out the long division calculation for B divided by A. For
example, if the program reads A = 1.7
and B = 37.2
, the
program should output
21
------
1.7 | 37.2
34
--
3.2
1.7
---
1.5
Remember that the result of dividing A by B is a pair of numbers
(q, r) with the properties
- A = B*q + r
- 0 <= r < B
The syntax for a number is
- A positive base-10 integer followed by an optional decimal point
followed by an optional positive base-10 integer. The numbers "1", "1." and
"1.2" are examples.
- A decimal point followed by a positive base-10 integer. The number
".1" is an example.
- A minus sign may immediately precede a number to indicate a negative
value.
- Unnecessary leading and trailing zeros should be suppressed on output.
Input will be a sequence of number pairs, separated by white space. invalid
input should terminate execution with an error message.
Output should be formatted to the example given above. Use use space
characters to align the numbers properly; do not use tabs to align the output
lines.