为什么输入6 8 10,输出的是3/10??
  • 板块P1888 三角函数
  • 楼主Pjcgs
  • 当前回复5
  • 已保存回复5
  • 发布时间2022/10/15 15:29
  • 上次更新2023/10/27 07:26:19
查看原帖
为什么输入6 8 10,输出的是3/10??
768410
Pjcgs楼主2022/10/15 15:29
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,temp;
    cin>>a>>b>>c;
    if(a>b)
    {
        temp=a;a=b;b=temp;
    }
    if(a>c)
    {
        temp=a;a=c;c=temp;
    }
    if(b>c)
    {
        temp=b;b=c;c=temp;
    }
    for(int i=1;i<c;i++)
    {
        if(a%i==0&&c%i==0)
        {
            a=a/i;
            b=b/i;
        }
        else break;
    }
    cout<<a<<"/"<<c<<endl;
    return 0;
}
2022/10/15 15:29
加载中...