View Code of Problem 66

#include<stdio.h>

int qiuyuexiao(int a,int b){
    int temp;
    int yinzi;
    if (a<b){
        temp=a;
    } else{
        temp=b;
    }
    for (int i = 1; i <=temp ; i++) {
        if (a%i==0&&b%i==0){
            yinzi=i;
        }
    }
    return yinzi;
}
int main(){
    int a,b;
    while (scanf("%d %d",&a,&b)!=EOF){
        if (a==b){
            printf("1\n");
        } else {
            int k = qiuyuexiao(a, b);
            printf("%d/%d\n", a / k, b / k);
        }
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 66