View Code of Problem 66

#include <stdio.h>

int gcd(int m, int n)
{
    int temp;
    while(n)
    {
        temp = n;
        n = m % n;
        m = temp;
    }
    return m;
}

int main(void)
{
    int a, b;
    while(scanf("%d%d",&a,&b) != EOF)
    {
        int k = gcd(a,b);
        if(a == b)
            printf("1\n");
        else
            printf("%d/%d\n",a / k, b / k);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 66