看了半天各种大手子解析, 也许是数学基础不好吧,熟练背诵吧。1234567891011121314151617181920212223242526272829303132using namespace std;int exgcd(int a, int b, int& x, int& y){ if(b == 0) { x = 1; y = 0; return a; } int r = exgcd(b, a % b, x, y); int t = x; x = y; y = t - (a / b) * y; return r;}bool linear_equation(int a, int b, int c, int &x, int &y){ int d = exgcd(a, b, x, y); if(c % d) return false; int k = c / d; x *= k; y *= k; return true;}int main(int argc, char const *argv[]){ int x, y; if(linear_equation(47, 30, 1, x, y)) cout << x << " " << y << endl; return 0;}