4.21

#include<iostream>
#include<vector>
using namespace std;


int main() {
    vector<int> i {1,2,3,4,5,6,7,8,9};
    for(auto e = i.begin();e != i.end();++e)
        cout << ((*e % 2 == 1) ? *e * 2 :*e) << endl;
    return 0;
}

4.22

#include<iostream>
#include<vector>
using namespace std;


int main() {
    int grade;
    while (cin >> grade)
        cout << ((grade >= 90) ? "high Pass" : (90 > grade && grade >= 75) ? "Pass" : (75 > grade && grade >= 60) ? "Low Pass" : "fail") << endl;
    return 0;
}
#include<iostream>
#include<vector>
using namespace std;


int main() {
    int grade;
    while (cin >> grade) {
        if (grade >= 90)
            cout << "High Pass" << endl;
        if (grade >= 60 && grade < 75)
            cout << "Low Pass" << endl;
        if (grade >= 75 && grade < 90)
            cout << "Pass" << endl;
        if(grade<60)
            cout << "fail" << endl;
    }

    return 0;
}
最后修改:2022 年 12 月 05 日
如果觉得我的文章对你有用,请随意赞赏