Untitled
unknown
plain_text
3 years ago
683 B
1
Indexable
#include<stdio.h> #include<math.h> int gcd(int a, int b, int*d1,int*x4,int*y4){ int x,y,d,x2=1,x1=0,y2=0,y1=1,q,r; if(b==0){ d = a; x = 1; return(d,x,y); } else if(b>0){ do{ q = floor(a/b); r = a - (q*b); x = x2 - (q*x1); y = y2 - (q*y1); a = b; b = r; x2 = x1; x1 = x; y2 = y1; y1 = y; }while(b>0); *d1 = a; *x4 = x2; *y4 = y2; return(a); } } int main(){ int a ,b,d,e,f,g ; printf("enter positive interger a"); scanf("%d",&a); printf("enter positive integer b such that a>=b"); scanf("%d",&b); g = gcd(a,b,&d,&e,&f); printf(" %d= %d x %d + %d x %d",d,a,e,b,f); }