PTA-輸出華氏-攝氏溫度轉換表
阿新 • • 發佈:2018-12-23
#include<stdio.h> #include<math.h> 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.