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