https://pintia.cn/problem-sets/994805260223102976/problems/994805268334886912
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef struct {
double up,down;
}fraction;
int gcd(int a,int b) //求最大公约数 辗转相除法
{
if (b) return gcd(b,a%b);
else return a;
}
int main()
{
fraction a,b;
int i,n;
scanf("%lf/%lf %lf/%lf %d",&a.up,&a.down,&b.up,&b.down,&n);
//用temp把两个分数通分到分母一致
double temp=a.down/n;
a.up/=temp;
a.down=n;
temp=b.down/n;
b.up/=temp;
b.down=n;
//求两个数谁大谁小 (测试点1)
double left,right;
left=min(a.up,b.up);
right=max(a.up,b.up);
//是求“之间”的数 不能取边界 (测试点2)
for (i=floor(left+1); i<right; i++){
if (gcd(i,n)==1){
printf("%d/%d",i,n);
if (i<(int)right)
printf(" ");
}
}
return 0;
}