View Code of Problem 66

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

Double click to view unformatted code.


Back to problem 66