Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        2年前关闭。
                                                                                            
                
        
#include<stdio.h>

int main()

{
   float fahrenheit;
   int celcius;

   celcius=(fahrenheit-32)*(5.0/9.0);

   printf("Enter your fahrenheit temperature : ");

   scanf("%f",&fahrenheit);

   printf("Your fahrenheit temperature in celcius is :%d\n",celcius);
}

最佳答案

这样做:

celcius=(ferenheit-32)*(5.0/9.0);


并不意味着celcius的值在任何时候都将始终为(ferenheit-32)*(5.0/9.0)。这意味着在遇到该语句时会将ferenheit设置为celcius。由于(ferenheit-32)*(5.0/9.0)在此语句运行时还没有值,因此ferenheit的值不确定。

您需要先读入celcius的值,然后根据该值计算ferenheit

printf("Enter your ferenheit temperature : ");
scanf("%f",&ferenheit);             // first read
celcius=(ferenheit-32)*(5.0/9.0);   // then calculate
printf("Your ferenheit temperature in celcius is :%d\n",celcius);


同样,它们被拼写为“摄氏”和“华氏度”。

10-08 03:34