📄 you.cpp
字号:
#include <iostream>
#include <string>
using namespace std;
void r(int a,int b)
{
if(b==0)
{
cout << "b will not be 0." << endl;
}
else
{
cout << a << "/" << b << endl;
}
}
int min(int a,int b)
{
if(a > b)
{
return b;
}
if(a < b)
{
return a;
}
return 0;
}
int gongyue(int a,int b)
{
if(b==0)
{
cout << "b will not be 0." << endl;
}
if(b!=0)
{
for(int i=2;i<=min(a,b);i++)
{
if(a%i==0 && b%i==0)
{
a=a/i;
b=b/i;
return gongyue(a,b);
}
else
{
continue;
}
}
if(b==1)
{
cout << "约分后:" << a << endl;
}
else
{
cout <<"约分后:" << a << "/" << b << endl;
}
}
return 0;
}
void input()
{
string y_l_s;
cout << "please enter r:";
cin >> y_l_s;
cout << y_l_s << endl;
}
void bijiao()
{
int a1,b1,a2,b2;
cout << "please enter the two number of r1:";
cin >> a1 >> b1 ;
cout << "please enter the two number of r2:";
cin >> a2 >> b2 ;
if(b1!=0 && b2!=0)
{
if(a1*b2 > a2*b1)
{
cout << "The biger rational is:r1" << endl;
gongyue(a1,b1);
}
if(a1*b2 == a2*b1)
{
cout << "The two rational is equal." << endl;
}
if(a1*b2 < a2*b1)
{
cout << "The biger rational is:r2" << endl;
gongyue(a2,b2);
}
}
if(b1==0 || b2==0)
{
cout << "b will not be 0." << endl;
}
}
void add()
{
int a1,b1,a2,b2;
cout << "please enter the two number of r1:";
cin >> a1 >> b1 ;
cout << "please enter the two number of r2:";
cin >> a2 >> b2 ;
if(b1!=0 && b2!=0)
{
gongyue(a1*b2+a2*b1,b1*b2);
}
if(b1==0 || b2==0)
{
cout << "b will not be 0." << endl;
}
}
void minu()
{
int a1,b1,a2,b2;
cout << "please enter the two number of r1:";
cin >> a1 >> b1 ;
cout << "please enter the two number of r2:";
cin >> a2 >> b2 ;
if(b1!=0 && b2!=0)
{
gongyue(a1*b2-a2*b1,b1*b2);
}
if(b1==0 || b2==0)
{
cout << "b will not be 0." << endl;
}
}
void chengfa()
{
int a1,b1,a2,b2;
cout << "please enter the two number of r1:";
cin >> a1 >> b1 ;
cout << "please enter the two number of r2:";
cin >> a2 >> b2 ;
if(b1!=0 && b2!=0)
{
gongyue(a1*a2,b1*b2);
}
if(b1==0 || b2==0)
{
cout << "b will not be 0." << endl;
}
}
void chufa()
{
int a1,b1,a2,b2;
cout << "please enter the two number of r1:";
cin >> a1 >> b1 ;
cout << "please enter the two number of r2:";
cin >> a2 >> b2 ;
if(b1!=0 && b2!=0)
{
gongyue(a1*b2,b1*a2);
}
if(b1==0 || b2==0)
{
cout << "b will not be 0." << endl;
}
}
void main()
{
int a,b;
//input();
cout << "please enter the two number:";
cin >> a >> b;
r(a,b);
//gongyue(a,b);
chufa();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -