L1-004 計算攝氏溫度 (5分)
給定一個華氏溫度 \(F\),本題要求撰寫程式,計算對應的攝氏溫度 \(C\),計算公式:\(C=5 \times \frac{F?32}{9}\),題目保證輸入與輸出均在整型范圍內,
輸入格式:
輸入在一行中給出一個華氏溫度,
輸出格式:
在一行中按照格式 Celsius = C 輸出對應的攝氏溫度 \(C\) 的整數值,
輸入樣例:
150
輸出樣例:
Celsius = 65
解題思路:
按要求輸出即可,注意先算乘法,后算除法,
代碼:
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
cin>>n;
cout<<"Celsius = "<<5*(n-32)/9<<endl;
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/52955.html
標籤:C++
下一篇:c++中的例外處理
