请问为什么c语言中求最大公约数时两个输入的数位置交换,导致结果不同

代码如下
/question 1/
#include <stdio.h>
#include <math.h>
int main()
{int a,b,i,c,d;
printf("please input the both number:");
scanf("%d,%d",&a,&b);
for(i=a;i>1;i--)
{c=a%i;d=b%i;
if(c==d==0)
{printf("the greatest commen divisor:%d",i);
break;}
}
return 0;
}
请问该如何修改

img

img

这句是这样的:if(c==0 && d==0) //(c==d==0),修改完善如下,供参考:

#include <stdio.h>
#include <math.h>
int main()
{
    int a,b,i,c,d;
    printf("please input the both number:");
    scanf("%d%d",&a,&b);
    for(i=a<b?a:b;i>1;i--)//修改
    {
        c=a%i;d=b%i;
        if(c==0 && d==0)   //(c==d==0)
        {
           printf("the greatest commen divisor:%d",i);
           break;
        }
    }
    return 0;
}