Issue with GCD recursive program

I've gotten an assignment about making a program that calculates the greatest common divisor (gcd) and its linear coefficients. I got the GCD part down but I can't seem to get my linear coefficients down.
Here's my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
using namespace std;

int gcd(int, int);
int extended_gcd(int a, int b, int x);
int main()
{
    int num1,num2,x,y;
    int *ret = new int[3];
    cout << "enter two integers:";
    cin >> num1 >> num2;
    
    cout << "gcd is " << endl;
    ret = extended_gcd(num1, num2,x);// << endl;
    cout << ret[0] << endl << ret[1] << endl << ret[2];
    system("pause");
    return 0;
    
}

/*/int gcd(int x, int y)
{
    if (x % y == 0)
    return y;
    else
    return gcd(y, x%y);
}
/*/
int extended_gcd(int a, int b, int x,int y)
{
    int q, r;
    double s, t;
    int n;
    
    if (b == 0)
      // return (1,0);
      cout << "x = 1" << endl << "y = 0";
       else
       {
       q = a/b;
       r = a%b;
       extended_gcd(a, b, b,r);
       extended_gcd(a,b,r, b);
       cout << "x = " << t << endl;
       cout << "y = " << (s-q*t) << endl;
       }
return (t, (s-q*t), n);


thanks for your help
Line 14 tries to save an integer value (the return type of extended_gcd()) to a pointer-to-int.
Line 47 is not an int.

You can declare a temporary array inside extended_gcd() and return a pointer to it, or pass (a pointer to) the array to the function as an argument.
Topic archived. No new replies allowed.