Pagini recente » Cod sursa (job #1944187) | Cod sursa (job #1769513) | Cod sursa (job #504287) | Cod sursa (job #2816750) | Cod sursa (job #313902)
Cod sursa(job #313902)
#include<stdio.h>
#include<stdlib.h>
int a,b,c,*d,*x,*y;
void euclid(int a, int b, int *d, int *x, int *y)
{
if (b == 0) {
*d = a;
*x = 1;
*y = 0;
} else {
int x0, y0;
euclid(b, a % b, d, &x0, &y0);
*x = y0;
*y = x0 - (a / b) * y0;
}
}
int main(void)
{
freopen("euclid3.in","r",stdin);
freopen("euclid3.out","w",stdout);
x=malloc(4); y=malloc(4);
d=malloc(4);
scanf("%d %d %d",&a,&b,&c);
euclid(a,b,d,x,y);
int rest;
rest=*d;
int rez=c/rest;
int aux=*x;
aux*=rez;
*x=aux;
aux=*y;
aux*=rez; *y=aux;
printf("%d ->%d\n",*x,*y);
return 0;
}