#include <stdio.h> #include <stdlib.h> #include <math.h> #define Max 50 int gcd(int a,int b) { int t; while(b!=0) { t=a%b; a=b; b=t; } return a; } int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF) { if(a==b) printf("1\n"); else printf("%d/%d\n",a/gcd(a,b),b/gcd(a,b)); } return 0; } |
Double click to view unformatted code.