View Code of Problem 66

#include<stdio.h>
#include<math.h>
#include<string.h>
#include <stdlib.h>
int main() {


	/*
	输出a除以b的结果,结果就分数表示,
	如,1除以2得1/2,2/4=1/2,如果a等于b,那么输出1。
	*/
	int a , b , x , y;
	
	while(scanf("%d %d" , &a , &b) != EOF){
		x = a; y = b;
		if( a == b)
			printf("1\n");
		int p = a * b;
		int r ;
		while( a > 0){
			r = b % a;
			b = a;
			a = r;
		}
		printf("%d/%d" , x/b , y/b );
	}
		
	return 0;
}












Double click to view unformatted code.


Back to problem 66