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