题解:洛谷 AT_abc397_a Thermometer

张开发
2026/4/16 1:35:18 15 分钟阅读

分享文章

题解:洛谷 AT_abc397_a Thermometer
【题目来源】洛谷AT_abc397_a [ABC397A] Thermometer - 洛谷 (luogu.com.cn)【题目描述】Takahashi measured his body temperature and found it to beX ∘ C X^{\circ}CX∘C.高桥测量了他的体温发现是 X 摄氏度。Body temperature is classified into the following:体温分类如下Higher than or equal to38 ∘ C : 38^{\circ}C:38∘C:“High fever”高于或等于 38 摄氏度高烧High feverHigher than or equal to37.5 ∘ C 37.5^{\circ}C37.5∘Cand lower than38 ∘ C : 38^{\circ}C:38∘C:“Fever”高于或等于 37.5 摄氏度且低于 38 摄氏度发烧FeverLower than37.5 ∘ C : 37.5^{\circ}C:37.5∘C:“Normal”低于 37.5 摄氏度正常NormalWhich classification does Takahashi’s body temperature fall into? Present the answer as an integer according to the Output section.高桥的体温属于哪一类根据输出部分的要求以整数形式给出答案。【输入】The input is given from Standard Input in the following format:X【输出】Print an integer specified below corresponding to Takahashi’s body temperature classification.High fever: 11Fever: 22Normal: 33【输入样例】40.0【输出样例】1【算法标签】#入门# #模拟#【代码详解】#includebits/stdc.husingnamespacestd;doublex;// 定义变量 x用于存储输入的温度值intmain(){cinx;// 输入温度值if(x38.0){// 如果温度大于等于 38.0cout1endl;// 输出 1}elseif(x37.5){// 如果温度大于等于 37.5 但小于 38.0cout2endl;// 输出 2}else{// 如果温度小于 37.5cout3endl;// 输出 3}return0;// 程序结束}【运行结果】40.0 1

更多文章