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;
}