PTA-输出华氏-摄氏温度转换表

#include
#include
float Celsius(int F);
int main()
{
  int lower,upper;
  scanf("%d %d",&lower,&upper);
  if(lower>upper||Celsius(lower)==Celsius(upper)==-1)//Check if what you inputed is right
      printf("Invalid.");
  else
  {
    printf("fahr celsius\n");
    for(;lower<=upper;lower+=2)//You need to put a sheet and the upper is just a upper limit.
    	printf("%d%6.1f\n",lower,Celsius(lower));// Of course, the lower is a threshord.  
  }
  return 0;
}
float Celsius(int F)
{
  float C;
  if(F>=0&&(abs(F-(int)F))<1E-8&&F<=100) // Check the scopes of the parameter values
  {
    C=5*(float)(F-32)/9;
    return C;
  } 
  else
    return -1;
}

Read the title and understand it clealy and throughly, and I only seem to depend on my litter experience at present.

你可能感兴趣的:(C语言基础题库之编程题)