View Code of Problem 66

#include <stdio.h>
main(){
	int a,b;
	int num1,num2,r,t;
	while(scanf("%d%d",&a,&b)!=EOF){
		if(a == b){
			printf("1\n");
			continue;
			}
		if(b < a){
			t = b; b = a; a = t;
		}
		num1 = a; num2 = b;
		while(num1 > 0&&num2>0){
			r = num1%num2;
			num1 = num2;
			num2 = r;
		}
		printf("%d/%d\n",a/num1,b/num1);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 66