是什麼意思??? 我最唔明係 i =j 係唔係要佢 返去%多一次??
#include
#include
int main(int argc, char *argv[])
{
int i,j,tmp;
printf(" enter your num \\n==> ");
scanf("%d %d",&i,&j);
while (j != 0)
{
tmp = i % j;
i =j;
j = tmp;
}
printf("the result is %d \\n",i);
system("pause");
return 0;
}
更新1:
那裡tmp = i % j; i =j; j = tmp; i=j會唔會返去tmp =i%j ???因為 我都唔明個i,j 行一次之後個值是什麼??
更新2:
/* if i = 4 , j = 14 */ int tmp, i , j ; while (j != 0) {tmp = i % j ~~~~~~~~ 4%14= 12 i = j ~~~~~~~~~~~ i = 14 j = tmp} ~~~~~~~~ j =12
更新3:
printf( %d \n,i); next loop~ tmp = 14 % 12 i = 12 j = 2 next loop~ tmp = 12 % 2 i = 2 j = 0 唔知我有冇理解錯????
更新4:
其實我想問why 要用 a % b 去找 HCF?? 我唔明個原理