以一些特出符号分隔的例子可用

public static void main(String [] args)
{
Scanner sc = new Scanner(System.in);
int a1,c1;
String data = sc.next();
String num [] = data.split("/");
int a = Integer.parseInt(num[0]);
int c = Integer.parseInt(num[1]);
a1 = a;
c1 = c;
int t;
while(c1!=0)
{
t = a1%c1;
a1 = c1;
c1 = t;
}
a = a/a1;
c = c/a1; //找最大公约数   (最小公倍数 = 两数乘积 / 最大公约数)
System.out.printf("%d/%d\n",a,c);
}

posted @   heartbeat111  阅读(29)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示