求最大公约数得方法:
/*
*Copyright (c) 2014,烟台大学计算机学院
*All gight reserved.
*文件名称:temp.cpp
*作者:邵帅
*完成时间:2014年10月30日
*版本号:v1.0
*
*问题描述:求最大公约数
*输入描述:两个数
*程序输出;两个数的最大公约数
*/
#include <iostream>
using namespace std;
int main( )
{
int a,b,r;
cin>>a>>b;
while (b!=0)
{
r=a%b;
a=b;
b=r;
}
cout<<a<<endl;
return 0;
}
运行结果:
知识点总结:了解了求最大公约数得方法。好吧、弥补了一下中学时得知识。
@ Mayuko