#include <iostream>
using namespace std;
int main() {
    int score;
    while (true) {
        cin >> score;
        if (score >= 0 && score <= 100) {
            cout << "成绩:" << score << endl;
            break;
        } else {
            cout << "输入有误,请重新输入" << endl;
        }
    }
    return 0;
}

1 条评论

  • @ 2023-12-10 15:23:06

    我猜else里面那个不需要输出 附议ac代码

    #include<bits/stdc++.h>
    
    using namespace std;
    
    int main()
    {
        int x;
        cin>>x;
        while(x<0||x>100)
        {
            cin>>x;
        }
        cout<<"成绩:"<<x;
    }
    
    • 1

    信息

    ID
    76
    时间
    1000ms
    内存
    256MiB
    难度
    5
    标签
    递交数
    69
    已通过
    25
    上传者