好的,所以我必须创建一个天气程序,当我尝试运行代码时,我没有收到任何错误,但它只会打印“输入起始温度”和“输入结束温度”。但是它不会让我为它输入数据。我有什么需要改变的吗?我知道我还没有完成代码,但我只是想在继续其余代码之前测试输入。谢谢您的帮助!
#include <stdio.h>
int main(int argc, char **argv)
{
float celcius, fahrenheit, kelvin, ending, interval;
int c, f, k, temp;
printf("which temperature is being input? (C,F,K) ");
scanf("%d", &temp);
if (temp == c)
{
printf("enter a starting temperature");
scanf("%f", &celcius);
printf("enter an ending temperature");
scanf("%f", &ending);
fahrenheit = celcius * 9 / 5 + 32;
kelvin = celcius + 273.15;
}
if (temp == f)
{
printf("enter a starting temperature");
scanf("%f", &fahrenheit);
celcius = fahrenheit - 32 * 5 / 9;
kelvin = fahrenheit - 32 * 5 / 9 + 273.15;
printf("enter an ending temperature");
scanf("%f", &ending);
if (temp == k)
{
}
printf("enter a starting temperature");
scanf("%f", &kelvin);
fahrenheit = kelvin - 273 * 1.8 + 32;
celcius = kelvin - 273.15;
printf("enter an ending temperature");
scanf("%f", &ending);
}
}