Discuz! Board

 找回密码
 立即注册
查看: 472|回复: 0

作业

[复制链接]

51

主题

54

帖子

8724

积分

论坛元老

Rank: 8Rank: 8

积分
8724

大牙狸 Lv:12
发表于 2023-1-11 17:33:21 | 显示全部楼层 |阅读模式
#include<bits/stdc++.h>
using namespace std;
int t,s,r=1,n,t1,s1;
int yin(int a,int b)
{
        while(r>=0)
        {
                r=a%b;
                if(r==0)
                {
                        break;
                }
                else
                {
                        a=b;
                        b=r;
                }
        }
        return b;
}

int bei(int c,int d,int e,int f)
{
        d=d*f/yin(d,f);
        c=d/yin(d,f)*c+f/yin(d,f)*f;
}

int main()
{
        scanf("%d/%d",&t,&s);
        scanf("%d/%d",&t1,&s1);
        yin(t,s);
        yin(t1,s1);
        bei(t,s,t1,s1);
        if(s==1)
        {
                cout<<t;
        }
        else
                cout<<t<<"/"<<s;
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|DiscuzX

GMT+8, 2025-5-30 12:00 , Processed in 0.055795 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.. 技术支持 by 巅峰设计

快速回复 返回顶部 返回列表