View Code of Problem 66

#include<stdio.h>
int gcd(int x, int y) {
	int temp;
	if(x > y) {
		temp=x;
		x=y;
		y=temp;
	}
	temp=y%x;
	while(temp!=0) {
		y=x;
		x=temp;
		temp=y%x;
	}
	return x;
}
int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if(a<=b) {
		int c=gcd(a, b);
		printf("%d/%d", a/c, b/c);
	}
}

Double click to view unformatted code.


Back to problem 66