Solução: Problema da simplificação das frações (Bruno Barbosa)

From AdonaiMedrado.Pro.Br
Revision as of 18:53, 12 June 2009 by 200.17.147.2 (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#include <stdio.h>
 
int analisaImprime(int num, int x, int y);
 
int analisaImprime(int i, int x, int y){
 
	while((x%i!=0)||(y%i!=0)){
		i--;
	}
	if((x%i == 0)&&(y%i==0))
		printf("%d %d\n", x/i, y/i);
 
	else
		printf("%d %d\n", x, y);
}
 
int main(){
 
	int n, m;
	scanf("%d %d", &n, &m);
 
	while(n || m){ 
 
		if(!n || !m){
 
			if(n != 0)
				printf("%d %d\n", n/n, m);
			if(m != 0)
				printf("%d %d\n", n, m/m);
		}
 
		else
			analisaImprime(n, n, m);  
 
		scanf("%d %d", &n, &m);
	}
}