分析问题
1 根据输入的温度t,输出不同的内容
2 判断条件:t>=20 且 t<=30
建立模型
- 读取输入的温度值
t- 如果
t大于等于 20 且小于等于 30,则:
- 打印 “OK”
- 否则:
- 打印 “NO”
编写代码
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;//temperature 的缩写
cin>>t;
if(t>=20 && t<=30){
cout<<"OK";
}else{
cout<<"NO";
}
return 0;
}