I've found this pseudocode from Wikipedia of Euclid's extended Algorithm, but I don't know how to return 2 values from a function.
function extended_gcd(a, b)
if b = 0
return (1, 0)
else
(q, r) := divide (a, b)
(s, t) := extended_gcd(b, r)
return (t, s - q * t)
Source: http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
The template class std::pair
could be used for this; i.e.,
if (b == 0)
return std::pair<int, int>(1, 0);