한국어<
中文
فارسی
English
ไทย
All Copyright Reserved 2010-2011 SDUSTOJ TEAM
GPL2.0 2003-2011 HUSTOJ Project TEAM
Anything about the Problems, Please Contact Admin:admin
#include<iostream>
#include<cstdio>
using namespace std;
int cccc(int a,int b){
if(!b)
return a;
return cccc(b,a%b);
}
class Fract{
public:
int n,m;
Fract(int a,int b):n(a),m(b)
{
int Max,Min,c,x,y;
if(a<0) a*=-1;
if(b<0) b*=-1;
c=cccc(max(a,b),min(a,b));
if(m<0)
{
n*=-1;
m*=-1;
}
if(c!=1)
{
n/=c;
m/=c;
}
}
void show()
{
if(n==0||m==1)
cout<<n<<endl;
else
{
cout<<n<<"/"<<m<<endl;
}
}
operator double()
{
return (double)n/m;
}
};
int main()
{
int n, m;
while(cin >> n >> m)
{
Fract fr(n, m);
cout << (double)fr << " ";
fr.show();
}
}