View Code of Problem 66

#include <stdio.h>
#include <math.h>
#include <string.h>
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
int main()
{
	int a, b, c;
	while (scanf("%d %d", &a, &b) != EOF) {
		if (a == b) {
			printf("1\n");
		}
		else {
			c = gcd(a, b);
			printf("%d/%d\n", a / c, b / c);
		}

	}
	return 0;
}

Double click to view unformatted code.


Back to problem 66