View Code of Problem 66

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

int main(){
	int f,tep,a,b,x[100],k,sum,i,ta,tb;
	while(scanf("%d %d",&a,&b)!=EOF){
		k=0;
		sum=1;
		ta=a;
		tb=b;
		if(ta>tb){
			tep=ta;
			ta=tb;
			tb=tep;
		}
			for(i=2;i<=ta;i++){
				if(ta%i==0&&tb%i==0){
					x[k++]=i;
					ta=ta/i;
					tb=tb/i;
					i=1;
				}
			}
		if(a==b){
			printf("%d\n",1);
		}else
			printf("%d/%d\n",ta,tb);
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 66