2011年计算机二级C++辅导实例编程(3)

2014-10-21 14:30:03 · 作者: · 浏览: 67

  两个数论的算法


  #include


  using namespace std;


  struct result


  {


  int d;


  int x;


  int y;


  };


  //d=gcd(a,b)=ax+by


  result ExtendeEuclid(int a,int b)


  {


  result res;


  if(!b)


  {


  res.d=a;


  res.x=1;


  res.y=0;


  return res;


  }


  编辑推荐: