Pagini recente » Cod sursa (job #774585) | Cod sursa (job #2036818) | Cod sursa (job #1649233) | Cod sursa (job #1333456) | Cod sursa (job #1991243)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
void euclid(int a, int b, int *c, int *x, int *y)
{
if(b == 0)
{
*c = a;
*x = 1;
*y = 0;
}
else
{
int x0, y0;
euclid (b, a%b, c, &x0, &y0);
*x = y0;
*y = x0 - a/b *y0;
}
}
int main()
{
int t;
while(t)
{
int a, b, c, x, y;
f >> a >> b >> c;
euclid(a, b, &c, &x, &y);
g << x << " " << y << "\n";
--t;
}
return 0;
}