*@Class计134~4
*@Author:薛富磊
*@Time:2013-11-23
*@Function:递归求最大公约数
*@Args: m n为输入的任意两个数
*@Return:最大公约数
*/
//递归解法
#include "iostream"
using namespace std;
int gcd(int ,int ); //函数声明
int main() //主函数
{
int m,n;
cout<<"输入两个数字:";
cin>>m>>n;
cout<<"最大公约数:";
cout<<gcd(m,n)<<endl;
}
int gcd(int a, int b) //求最大公约数的递归函数
{
int x;
if (b==0) // b=0 为a
x=a;
else
x=gcd(b,a%b); //不为0 取余数
return x;
}
第十三周——递归求最大公约数
