题解 | #最大公约数#
最大公约数
https://www.nowcoder.com/practice/20216f2c84bc438eb5ef05e382536fd3
#include <iostream> using namespace std; int findmaxy(int a,int b){ if(a==0) return b; else if(b==0) return a; else if(a>b) return findmaxy(a%b, b); else if(a<b) return findmaxy(a,b%a); else return a; } int main() { int x,y; while(cin>>x>>y){ cout<<findmaxy(x, y)<<endl; } }