Source Code
#include<stdio.h>

int main(){
     
    
     int a,b,l1,r1,l2,r2;
     float q;
     double min=10000;
     scanf("%d%d%d%d%d%d",&a,&b,&l1,&r1,&l2,&r2);
      int x=l1,y=l2,x1,y1;
      int i,j;
     while (l1<= x <=r1 && l2<= y <=r2 ){
             for (j=y;j<=r2;j++){
               for (i=x;i<=r1;i++)
              { 
                q=(float)i/j-(float)a/b;
                if (q<0)
                q=-1*q;
                if (q<min){min=q;
                x1=i;
                y1=j;}
              }
            
             }  
            
           if (i==r1+1 && j==r2+1) break;}

           
    

printf("%d %d",x1,y1);
Copy
Fractions Reem-Assi
GNU GCC C11
0 ms
0 KB
Compilation Error