#include <stdio.h>
#include <stdlib.h>
int main()
{
int a ;
int b ;
int c ;
int d ;
printf ("分母") ;
scanf ("%d" , &a );
printf ("分子") ;
scanf ("%d" , &b );
printf ("分母") ;
scanf ("%d" , &c );
printf ("分子") ;
scanf ("%d" , &d );
int mom ;
int son ;
mom = a*c ;
son = a*d + b*c ;
int in = 1 ;
int inn = 1 ;
while ( (in<mom) && (in<son) ) {
if ((mom % in) ==0 ) {
if ((son% in ) ==0 ){
inn = in ;
printf("%d " , in) ;
}
}
in= in+1 ;
}
son = son/inn ;
mom = mom/inn ;
printf("分母是%d 分子是%d" , mom , son) ;
system("PAUSE");
return 0;
}
沒有留言:
張貼留言