#include<stdio.h> #include<stdlib.h> int fun(int a, int b); int main() { int a,b,max; while(scanf("%d %d",&a,&b)!=EOF){ if(a==b) printf("1\n"); else{ max=fun(a,b); a=a/max; b=b/max; printf("%d/%d\n",a,b); } } } int fun(int a,int b){ int temp,max; if(a>b) temp=b; else temp=a; for(int i=temp;i>=1;i--){ if(a%i==0&&b%i==0){ max=i; break; } } return max; } |
Double click to view unformatted code.