High-Precision decimal,
Subject content:
Due to the limitation of the internal expression of the computer, there are Precision Problems in floating point operations. To obtain high-precision computing results, you need to design your own implementation method.
Any floating point number between (0, 1) can be expressed as the quotient of two positive integers. To express the quotient of the two numbers, the result of division can be expressed as multiple integers, each integer represents one digit of the result. That is to say, the first digit of the quotient is represented by an integer, the second digit is represented by another integer, and so on, a high precision division result can be output.
For example, if the result of 16/19 is 0. 8421052631..., 8, 4, 2, 1, 0, 5, 2, 6, 3, and 1 are output in sequence ....
The process of division can be used to simulate the method of dividing by vertical manually columns. Multiply the devisor by 10 first. After obtaining a quotient, multiply the remainder by 10 as the devisor for the next round of calculation:
160/19-> 8 + 8
80/19-> 4 + 4
...
When the remainder is 0, the remainder is exhausted.
Now, write a program, enter a score, and calculate its decimal form. Whether or not the decimal point can be exceeded, the output can be up to 200 digits after the decimal point.
Input Format:
Shape
A/B
10 <= a <B <100. That is to say, the decimal point must be a positive number smaller than 1.
Tip: the input contains "/" in the middle of two numbers. Therefore, scanf should adopt the input format "% d/% d.
Output Format:
Shape
0. xxxxxxxxx
Decimal point, which can be up to 200 digits after the decimal point. When the output ends, wrap the line with a carriage return. If a/B is a finite, non-repeating decimal number, all the valid bits are output. You do not need to output the following 0 to fill the 200 BITs.
# Include <stdio. h>
Int main ()
{
Int n, m, c = 0;
Scanf ("% d/% d", & n, & m );
Printf ("0 .");
While (c <200 ){
C ++;
N * = 10;
Printf ("% d", n/m );
N % = m;
If (n = 0)
Break;
}
Return 0;
}