So I have to create a program that properly uses the extended euclid algorithm. I think I have most of what I need but I seem to be stuck. I know I have some parts missing and would appreciate any help. I apologize if my code is written poorly, I'm new to C++. Thanks in advance.
#include <iostream>
#include <strings>
usingnamespace std;
int main(void) {
int a, b, x, y , d, tmp;
cout << "Enter a number for a" << endl;
cin >> a;
cout << "Enter a number for b" << endl;
cin >> b;
if (a<b) {
tmp = a;
a = b;
b = tmp;
}
while(b != 0) {
int tmp = a % b;
a = b;
b = tmp;
}
cout << endl;
cout << b << endl;
return 0;
}
int extEuclid(int a, int b, int &lastx, int &lasty) {
d = extEuclid(a,b,x,y)
int quotient = a % b;
while(b != 0)
tmp = x;
x = (lastx - quotient * x);
lastx = tmp;
temp = y;
y = (lasty - quotient * y);
lasty = tmp;
return (lastx, lasty);
}