1 条题解

  • 0
    @ 2025-9-17 21:42:28

    核心逻辑

    判断输入温度 t 是否在区间 [25, 30] 内:若满足则输出 ok!(适合晨练),否则输出 no!(不适合)。

    代码实现

    C

    #include <stdio.h>
    
    int main() {
        double t;  // 兼容整数和小数温度
        scanf("%lf", &t);
        if (t >= 25 && t <= 30) {
            printf("ok!\n");
        } else {
            printf("no!\n");
        }
        return 0;
    }
    

    C++

    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        double t;
        cin >> t;
        cout << (t >= 25 && t <= 30 ? "ok!" : "no!") << endl;
        return 0;
    }
    

    Python

    t = float(input())
    print("ok!" if 25 <= t <= 30 else "no!")
    
    • 1

    信息

    ID
    21
    时间
    1000ms
    内存
    64MiB
    难度
    3
    标签
    递交数
    52
    已通过
    29
    上传者