View Code of Problem 66

#include<stdio.h>
int gongyueshu(long int a,long int b)
{
	while(a!=b)
	{
	   if(a>b)
	     a=a-b;
	   else
	     b=b-a;
	}
	return a;
}
int main()
{
	long int a,b;
	while(scanf("%ld %ld",&a,&b)!=EOF)
	{
	   int i;
	   if(a!=1)
	   {
	   	if(a==b)
	   	  printf("1\n");
	   	else
	   	{  
	      long int c=gongyueshu(a,b);     
	      printf("%ld/%ld\n",a/c,b/c); 
	    }
	   }
	   else{
	   	if(b==1)
	   	  printf("1\n");
	   	else
	   	  printf("%ld/%ld\n",a,b);
	   } 
	    
	}
}

Double click to view unformatted code.


Back to problem 66