Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int gcdExtended(int a, int b, int *x, int *y)
- {
- if (a == 0)
- {
- *x = 0;
- *y = 1;
- return b;
- }
- int x1, y1;
- int gcd = gcdExtended(b%a, a, &x1, &y1);
- *x = y1 - (b / a) * x1;
- *y = x1;
- return gcd;
- }
- int main() {
- int x, y;
- int a,b;
- cout << "Vuvedi dvete chisla" << endl;
- cin >> a >> b;
- x = 0;
- y = 0;
- int rez = gcdExtended(a, b, &x, &y);
- int broiteglilki = abs(x) + abs(y);
- cout << "Gcd = " << rez << " x = " << x << " y = " << y << " Broi teglilki: " << broiteglilki <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement