close
#include <stdio.h>
#include <stdlib.h>
/* recursive GCD */
int GCD(int t,int v)
{
if(t%v==0)
{
return v;
}
else
return GCD(v,t%v);
}
int main()
{
printf("請輸入兩個數\n");
int a,b;
scanf("%d",&a);
scanf("%d",&b);
int temp;
int t1;
int t2;
t1=a;
t2=b;
if(b>a)
{
temp=a;
a=b;
b=temp;
}
printf("GCD( %d , %d ) = %d\n",t1,t2,GCD(a,b));
}
全站熱搜
留言列表