| Varianta 25 / Subiectul 3 / Problema 4 |
#include<iostream.h>
#include<math.h>
long a,b,c;
double x;
long cmmdc(long a,long b)
{while(a!=b)
if(a>b)a=a-b;
else b=b-a;
return a;
}
void main()
{cin>>x;
b=1;
while(x-floor(x))
{x=x*10;
b=b*10;
}
a=x;
c=cmmdc(a,b);
a=a/c;
b=b/c;
cout<<a<<" "<<b;
}
|