菜鸟问题if(m%min==0&&n%min==0)可能被替换为 while(m%min==0&&n%min==0);
#include<stdio.h>
void main()
{
int m,n,min,max;
printf("Please input the first numble:\n");
scanf("%d",&m);
printf("Please input the second numble:\n");
scanf("%d",&n);
max=m>n?m:n;
min=m<n?m:n;
for(min;(m%min==0&&n%min==0);min--)
{
printf("The max is %d\n",min);
break;
}
for(max;if(max%n==0&&max%m==0);max++)
{
printf("The min is %d",max);
break;
}
}
上面的红色字体可不可以被以下一段代码代替:
do
{
min--;
printf("The max is %d\n",min);
}
while(m%min==0&&n%min==0);
do
{
max++;
printf("The min is %d",max);
}
while(max%n==0&&max%m==0);
}
请问错在什么地方,谢谢