欧几里得算法的目的是求出两个整数的最大公约数。
在程序中一般用gcd表示。
#include <iostream>
#include <map>
#include <string>
#include <stdio.h>
using namespace std;
int gcd(int a,int b){
while(b>0){
int ans=a%b;
a=b;
b=ans;
}
return a;
}
int main(){
int a,b;
while(scanf("%d%d",&a,&b)){
printf("%d\n",gcd(a,b));
}
return 0;
}