#include <stdio.h>
int gcd(int a,int b)
{
if(a<b)
return gcd(b,a);
if(a%b==0)
return b;
else
gcd(b,a%b);
}
int main(){
int a,b;
if (scanf("%d/%d",&a,&b)!=EOF){
// 分析不敲钟的时间
int gcd_value = gcd(a,b);
printf("%d/%d",a/gcd_value,b/gcd_value);
}
else{
printf("input wrong");
}
return 0;
}
代码来自:https://yunjinqi.top/article/237