题解 | #最大公约数#辗转相处
最大公约数
https://www.nowcoder.com/practice/20216f2c84bc438eb5ef05e382536fd3
#include <stdio.h>
int main() {
int a,b,t;
scanf("%d %d",&a,&b);
if(a==b){
printf("%d\n",a);
}
if(a<b){
t=a;
a=b;
b=t;
}
while(1){
t=b;
a=a%b;
//printf("(%d)\n",b);
if(a==0){
printf("%d\n",t);
return 0;
}
else{
t=a;
a=b;
b=t;
}
// printf("*%d %d*\n",a,b);
}
}
