Solução: Problema da simplificação das frações (Bruno Barbosa)
From AdonaiMedrado.Pro.Br
Revision as of 19:10, 5 June 2009 by 200.17.147.2 (Talk)
#include <stdio.h> int main(){ int n, m, i, teste; scanf("%d %d", &n, &m); while(n || m){ if(!n || !m){ printf("%d %d\n", n, m); } else{ if(n==m){ i = m; printf("%d %d\n", n/i, m/i); } if(n>m){ i = m; while((m%i!=0)&&(n%i!=0)){ i--; } if((m%i == 0)&&(n%i==0)) printf("%d %d\n", n/i, m/i); else printf("%d %d\n", n, m); } if(n<m){ i = n; while((m%i!=0)&&(n%i!=0)){ i--; } if((m%i!=0)&&(n%i!=0)) printf("%d %d\n", n/i, m/i); else printf("%d %d\n", n, m); } } scanf("%d %d", &n, &m); } }