『求助』do...while语句一输入Y就出错
# include <stdio.h>int fun(int n, int m)
{
int t,i, x, y;
if(n < m)
{
t = n;
n = m;
m = t;
}
t = n*m;
if(n % m == 0)
{
return n;
}
else
{
for(; m!=0;)
{
i = n%m;
n = m;
m = i;
}
x = n;
y = t/x;
return y;
}
}
int main(void)
{
int i, j, k;
char ch;
do
{
for(k=1; k>0;)
{
printf("请输入两个正整数:");
scanf("%d %d", &i, &j);
if(i<0 || j<0)
{
printf("输入数据不合规定,请重新输入!\n");
}
else
--k;
}
printf("%d和%d的最小公倍数是%d\n", i, j, fun(i, j));
printf("按y键继续下一组输,任意键退出\n");
scanf(" %c", ch);
}
while(ch=='y' || ch=='Y');
printf("已成功退出\n");
return 0;
}