求两个数的最大公约数

#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdlib>


using namespace std;

int main() {
    int a, b, gcd;

    cin >> a >> b;

    gcd = a > b ? b : a;

    while (gcd>1 && (a%gcd!=0||b%gcd!=0))
    {
        gcd--;
    }
    cout << gcd << endl;

 

 

    return 0;
}

posted @ 2023-08-29 17:38  江南王小帅  阅读(13)  评论(0)    收藏  举报