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