PTA浙大版《C语言程序设计(第3版)》题目集
练习2-12 输出华氏-摄氏温度转换表 (15分)
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int lower, upper;
scanf("%d %d", &lower, &upper);
if( lower <= upper && upper <= 100)
{
printf("fahr celsius\n");
while( lower <= upper )
{
printf("%d%6.1f\n", lower, ( lower - 32 ) / 9.0 * 5);//注意:这里输出%d与%f之间不能有空格
lower += 2;
}
}
else
printf("Invalid.");
return 0;
}