#include <iostream>
#include <stdio.h>
using namespace std;
int exgcd(int a,int b,int &x,int &y)
{
if(b==0)
{ //1的情况
x=1;
y=0;
return a;
}
int r=exgcd(b, a%b, x, y);
int t=y;
y=x-(a/b)*y; //2的情况
x=t;
return r;
}
int main()
{
int x,y;
exgcd(252,198, x, y);
cout<<"252x+198y=18的一个整数解为:"<<endl;
cout<<"x="<<x<<" "<<"y="<<y<<" "<<endl;
return 0;
}
来源:https://blog.csdn.net/qq_37765455/article/details/100980827