#include <stdio.h> int main() { double f = 0; double c = 0; scanf("%lf", &f); if (f >= 1 && f <= 100000) { c = 5.0 / 9 * (f - 32); printf("%.3lf", c); } return 0; }
#include <stdio.h> int main(void) { float temp; scanf("%f", &temp); // 两个整数相除,如有小数则商向下取整: // 如5 / 9 = 0.5,因为5和9属于整型常量,0.5会向下取整得到0 // 所以此处使用浮点型常量5.0参与运算,得到一个浮点型的商 printf("%.3f", 5.0 / 9 * (temp - 32)); return 0; }
#include<stdio.h> int main() { float f,c; scanf("%f",&f); c = 5.0/9.0*(f-32.0); printf("%.3f\n",c); return 0; }
#include <stdio.h> int main() { double f,c; //用double类型可以保证运算精度 scanf("%lf",&f); if(1 <= f <= 100000) { c = (double)5 / 9 *(f - 32) ; //注意强转,不然会先输出0 printf("%.3lf",c); } return 0; }
#include<stdio.h> int main() { float f; scanf("%f",&f); float c=(5.0/9.0)*(f-32.0); printf("%.3f",c); return 0; }