Scores can be expressed as "Numerator/Denominator. Write a program that requires the user to enter a score and divide the score into the simplest fraction. The simplest fraction means that the numerator and denominator do not have any components that can be divided. For example, 6/12 can be divided into about 1/2. When the numerator is greater than the denominator, it does not need to be expressed as an integer or a score, that is, 11/8 or 11/8. When the denominator is equal, it is still expressed as a score of 1/1.
Input Format:
Enter a score in a row. The numerator and denominator are separated by a slash (/), for example:12/34
It indicates 12 out of 34. Both the numerator and denominator are positive integers (excluding 0, if the definition of positive integers is unclear ).
Tip: Add "/" to the scanf format string to let scanf handle this slash.
Output Format:
Output the simplest fraction corresponding to the score in a row. The format is the same as that of the Input. That is, the score is expressed in the form of "Numerator/Denominator. For example5/6
It indicates 5 out of 6.
Input example:
60/120
Output example:
1/2
1 # include <stdio. h> 2 3 int main () 4 {5 Int Divident, divisor; // Divident is the denominator, divisor is the molecule 6 scanf ("% d/% d", & Divident, & divisor); 7 8 int A = Divident; 9 int B = divisor; 10 int t; 11 while (B> 0) // calculate the Divident and divisor's maximum common approx. 12 {13 T = A % B; 14 A = B; 15 B = T; 16} 17 printf ("% d/% d", Divident/a, divisor/a); 18 19 Return 0; 20}