08:温度表达转化

OpenJudge-1.3编程基础之算术表达式与顺序执行-08:温度表达转化
总Time Limit: 1000ms     Memory Limit: 65536kB

Description

利用公式 C = 5 * (F-32) / 9 (其中C表示摄氏温度,F表示华氏温度) 进行计算转化。

Input

输入一行,包含一个实数f,表示华氏温度。(f >= -459.67)

Output

输出一行,包含一个实数,表示对应的摄氏温度,要求精确到小数点后5位。

Sample Input

41

Sample Output

5.00000

Hint

C/C++,使用double

Source

习题(3-12)

C++ Code

#include<bits/stdc++.h>
using namespace std;
int main()
{
      double f,c;
      cin>>f;
      c=5*(f-32)/9;
      cout<<fixed<<setprecision(5)<<c;
      return 0;
}

C Code

#include<stdio.h>
int main()
{
      double f,c;
      scanf("%lf",&f);
      c=5*(f-32)/9;
      printf("%.5lf",c);
      return 0;
}
posted @ 2020-08-29 15:21  Programmer-sun  阅读(570)  评论(0编辑  收藏  举报