#include<stdio.h>
int main(){
int a,b;
int r;
scanf("%d%d",&a,&b);
do{
r=a%b;
a=b;
b=r;
}
while(r!=0);
printf("%d",a);
}
此方法是采用欧几里得算法,简单易懂,代码逻辑清晰
#include<stdio.h>
int main(){
int a,b;
int r;
scanf("%d%d",&a,&b);
do{
r=a%b;
a=b;
b=r;
}
while(r!=0);
printf("%d",a);
}
此方法是采用欧几里得算法,简单易懂,代码逻辑清晰