标签:
1 //约分最简分式 2 //先求最大公约数,然后将分子分母同时除以最大公约数 3 4 #include <stdio.h> 5 int main(){ 6 int numerator,denominator,temp,a,b; 7 char c; 8 scanf("%d%c%d",&numerator,&c,&denominator); 9 a=numerator; 10 b=denominator; 11 12 while(b!=0){ 13 temp=a%b; 14 a=b; 15 b=temp; 16 } 17 numerator/=a; 18 denominator/=a; 19 printf("%d/%d",numerator,denominator); 20 return 0; 21 }
标签:
原文地址:http://www.cnblogs.com/xingyazhao/p/5929590.html