C语言辗转相除求最大公约数

#include<iostream>
using namespace std;
int gcd(int x,int y)
{
    if(y==0)return x;
    else
    return gcd(y,x%y);
}
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        printf("%d\n",gcd(n,m));
    }

猜你喜欢

转载自blog.csdn.net/qq_42778026/article/details/88804926