wex10_11.cpp
来自「数据结构C++代码,经典代码,受益多多,希望大家多多支持」· C++ 代码 · 共 31 行
CPP
31 行
#include <iostream.h>
#pragma hdrstop
// recursively computes the GCD of m and n
int gcd(int a, int b)
{
int remainder = a % b;
if (remainder == 0)
return b;
else
return gcd(b,remainder);
}
void main(void)
{
int a, b;
cout << "Enter a and b: ";
cin >> a >> b;
cout << "Greatest common divisor of " << a << " and "
<< b << " is " << gcd(a,b) << endl;
}
/*
<Run>
Enter a and b: 45 155
Greatest common divisor of 45 and 155 is 5
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?