對不起,沒有添加代碼。愚蠢的錯誤在我身上。數學方程式不會被讀取。爲什麼是這樣?
#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);
}
}
所以它要求什麼溫度輸入和起始溫度,但爲什麼不計算數學公式?
您需要說出發生了什麼。 – occulus
c,f,k ..來自哪裏? – user2864740
'c','f'和'k'是什麼?你是否打算打印'celcius','華氏'和'開爾文'? – Kninnug