View Code of Problem 66

#include  <stdio.h>
#include  <stdlib.h>
#include  <math.h>
#include  <string.h>

int GCD(int a, int b)
{
	int t;
	for (;;)
	{
		if(b==0)
		{
			return a;
		}
		else
		{
			t=a;
			a=b;
			b=t%b;
		}
	}
	return 0;
}
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