close

#include <stdio.h>
/* while loop GCD */

int GCD(int a,int b)
{
while(a%b!=0)
{
b=a%b;
}

return b;
}


int main()
{
printf("Input a and b:\n");

int a,b;
scanf("%d%d",&a,&b);

int t1,t2;
t1=a;
t2=b;

int temp;
if(a<b)
{
temp=a;
a=b;
b=temp;
}

printf("GCD(%d,%d)=%d",t1,t2,GCD(a,b));

}

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

    nini的部落格

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