花式GCD

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
 int gcd1( int a, int b)
{
    int r;
    while(b>0)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int gcd2(int a,int b)
{
    while(b^=a^=b^=a%=b);
    return a;
}
int main()
{
    int a,b;
    while (scanf("%d,%d",&a,&b)!=EOF) printf("%d\n",gcd(a,b));
}

posted @ 2016-04-22 08:34  Code-dream  阅读(106)  评论(0编辑  收藏  举报