C|求最大公约数的伪代码


If y is equal to 0, then gcd(x, y) is x; otherwise,gcd(x,y) is gcd(y,x % y), where % is the modulus operator.
【C|求最大公约数的伪代码】代码:

#include using namespace std; int gcd(int x, int y) { if(y == 0) return x; else return gcd(y,x%y); } int main() { cout << gcd(8,4) << endl; return 0; }



    推荐阅读