一些常用的基础函数实现

1.求公约数

// return the greatest common divisor
int gcd(int v1, int v2)
{
  while(v2)
  {
    int temp = v2;
    v2 = v1%v2;
    v1 = temp;
  }
  return v1;
}

2.

原文地址:https://www.cnblogs.com/sylar-liang/p/4564759.html