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));
}

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 布拉怡 的頭像
    布拉怡

    nini的部落格

    布拉怡 發表在 痞客邦 留言(0) 人氣()