View Code of Problem 66

#include <stdio.h>
using namespace std;
int main(){
	int a,b;
	while(~scanf("%d%d", &a, &b)){
		if( a==b ){
			printf("1\n");
			continue;
		}
		if( a>b ){
			int temp = a;
			a = b;
			b = temp;
		}
		int c = a,d = b;
		while( a>0 ){
			int d = b%a;
			b = a;
			a = d;
		}
		printf("%d/%d\n", c/b, d/b );
		
	}

	return 0;
	
}

Double click to view unformatted code.


Back to problem 66