以下代码 输入值是24 18 执行后 判断if ((a % c) == 0 && (b % c) == 0)为真,此时c==6,但没有打印c的值,谢谢了~!
按了F10查看值,就是直接跳过打印的部分了
#include<stdio.h>
int main()
{
int a = 0;
int b = 0;
int c = 0;
scanf("%d %d",&a,&b);
if (a < b)
{
c = a;
for (;(a % c) != 0 && (b % c) != 0;c -= 1)
{
if ((a % c) == 0 && (b % a) == 0)
printf("%d", c);
break;
}
}
else if(a>b)
{
c = b;
for (;(a % c) != 0 || (b % c) != 0;c -= 1)
{
if ((a % c) == 0 && (b % c) == 0)
{
printf("%d", c);
break;
}
}
}
return 0;
}