最大公约数

View Code
 1 #include<stdio.h>
 2 int gcd(int x,int y)
 3 {
 4     int r;
 5     while(y!=0)
 6     {
 7         r=x%y;
 8         x=y;
 9         y=r;
10     }
11     return x;
12 }
13 int main()
14 {
15     int a,b;
16     while(~scanf("%d%d",&a,&b))
17     {
18         printf("%d\n",gcd(a,b));
19     }
20 }
原文地址:https://www.cnblogs.com/1114250779boke/p/2643080.html