#include<iostream> using namespace std; int main() { int a,b; while(cin>>a>>b) { int ax=0,bx=0,t=0; int temp; if(a==b) cout<<1<<endl; else if(a>b) { temp=a;a=b;b=temp; } else{ for(int i=a+1;i>1;i--) { if(a%i==0&&b%i==0) { ax=a/i; bx=b/i; t++; } } if(t==0) { cout<<a<<"/"<<b<<endl; } else { cout<<ax<<"/"<<bx<<endl; } } } } |
Double click to view unformatted code.