View Code of Problem 66

#include <stdio.h>
#include <stdlib.h>
int f(int a,int b)
{
    int c=a%b;
    while(c!=0)
    {
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}
int main()
{
    int m,n,a,x,y;
    while(scanf("%d%d",&m,&n)!=EOF)
    {
        if(m==n)
        {
            printf("1\n");
        }
        else
        {
    a=f(m,n);
    x=m/a;
    y=n/a;
    printf("%d/%d\n",x,y);
        }

    }
    return 0;
}

Double click to view unformatted code.


Back to problem 66