#include<stdio.h> #include<conio.h> main(){ int x,y,residuo=1,cociente,temp,temp1,temp2; printf("Introduce primer numero:n"); scanf("%d",&x); printf("Introduce segundo numero:n"); scanf("%d",&y); temp1=x; temp2=y; if(x<y){ temp=x; x=y; y=temp; } while(residuo!=0){ cociente=x/y; residuo=x%y; if(residuo<0){ if(cociente<0) cociente-=1; if(cociente>=0)cociente+=1; residuo=x-(y*cociente); } printf("%d = (%d)X(%d) + %dn",x,y,cociente,residuo); x=y; y=residuo; } if(x<0) x=-x; printf("nEl mcd(%d,%d)= %d",temp1,temp2,x); getch(); }
Para enviar comentarios debes estar registrado.
(c) ElRincondelC.com
Un proyecto de Urlan Heat : proyectos de Internet y soporte para el comercio electrónico.