View Code of Problem 66

#include<bits/stdc++.h>
using namespace std;
int gcd(int,int);
int main(){
	int a,b,t;
	while(scanf("%d%d",&a,&b)!=EOF){
		if(a == b)cout<<1<<endl;
		else {
			t = gcd(a,b);
			printf("%d/%d\n",a/t,b/t);	
		}
		
	}
	
	return 0;
} 
int gcd(int a,int b){
	if(b == 0)return a;
	else return gcd(b,a%b);
}

Double click to view unformatted code.


Back to problem 66