分数的加减乘除如何用程序实现?
#include<iostream>
#include<cmath>
struct beg
{
int up; //表示分数的分子
int down; //表示分数的分母
};
beg reduction(beg a);
beg add(beg a,beg b);
beg redu(beg a,beg b);
beg mul(beg a,beg b);
beg div(beg a,beg b);
int gcd(int a,int b);
using namespace std;
int main()
{
beg a,b; //a,b是两个分数
cout<<"请输入第一个分数:";
cin>>a.up>>a.down;
cout<<"请输入第二个分数:";
cin>>b.up>>b.down;
a=reduction(a); //化简分数
b=reduction(b);
beg c[4]