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