很抱歉没有添加整个代码。我的愚蠢错误。
#include <stdio.h>
int main(int argc, char ** argv) {
float celcius, fahrenheit, kelvin, interval;
int c, f, k;
char temp;
printf("which temperature is being input? (C,F,K) ");
scanf("%s", &temp);
if(temp == 'c') {
printf("enter a starting temperature");
scanf("%f", &celcius);
fahrenheit=celcius*9/5+32;
kelvin=celcius+273.2;
printf("%f, %f, %f", celcius, fahrenheit, kelvin);
}
else if(temp == 'f') {
printf("Please enter a starting temperature");
scanf("%f", &fahrenheit);
celcius=fahrenheit-32*5/9;
kelvin=fahrenheit-32*5/9+273.2;
printf("%f, %f, %f", celcius, fahrenheit, kelvin);
}
else if(temp == 'k') {
printf("enter a starting temperature");
scanf("%f", &kelvin);
fahrenheit=kelvin-273*1.8+32;
celcius=kelvin-273.2;
printf("%f, %f, %f", celcius, fahrenheit, kelvin);
}
}
所以它询问输入的温度和起始温度,但为什么不计算数学方程?