不知道楼主是不是想要这样的效果?
我想,既然输入数字以外的任意字符都退出,Q也会在其中,也就没有必要再把它设成一个条件了,所以只要是输入数字外的任何字符,都算退出条件。程序是用楼主的程序改的,有些简陋,谨作参考。
程序代码:#include<stdio.h>
#include<string.h>
#define Y {char c;c=getch()!='\n';}
#define M "请输入任意数字继续,其它键退出\n"
int Temperautre(double Fahrenheit);
int main(void)
{
double Fahrenheit;
char a;
while(1)
{
printf("Please enter another value:");
scanf("%lf",&Fahrenheit);
Y;
Temperautre(Fahrenheit);
puts(M);
a=getch();
if(a<'0'||a>'9') break;
}
return 0;
getch();
}
int Temperautre(double Fahrenheit)
{
const double Celsius = 1.8 * Fahrenheit + 32.0;
const double Kelvin = Celsius + 273.16;
printf("%.2lf fahrenheit is %.2lf celsius or %.2lf kelvin\n",Fahrenheit,Celsius,Kelvin);
}




