1、求两个正整数的最大公约数
请编写程序,求两个正整数的最大公约数。
输入格式:
输入在一行中给出一对正整数 0<x,y≤10^6,数字间以空格分隔。
输出格式:
在一行中输出 x 和 y 的最大公约数。
输入样例:
73472 48503
输出样例:
287
#include <iostream>
using namespace std; //std::
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv\[\]) {
long long a=0,b=0,c=0;
cin>>a>>b;
for(int i=1;i<=a;i++){
if(a%i==0&&b%i==0){
if(i>c){
c=i;
}
}
}
cout<<c<<endl;
return 0;
}

