View Code of Problem 66

#include <bits/stdc++.h>
using namespace std;

int gcd(int a,int b) {
	while(b) {
		int temp = a%b;
		a=b;
		b=temp;
	}	
	return a;
}

int main()
{
	int a,b;
	while(cin>>a>>b) {
		if(a==b) cout<<1<<endl;
		else {
			int c=gcd(a,b);
//			cout<<c;
			a/=c;
			b/=c;
			cout<<a<<"/"<<b<<endl;
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 66