#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int> scores(n);
    for (int i = 0; i < n; i++) {
        cin >> scores[i];
    }

    int maxScore = scores[0];
    int minScore = scores[0];
    for (int i = 0; i < n; i++) {
        if (scores[i] > maxScore) {
            maxScore = scores[i];
        }
        if (scores[i] < minScore) {
            minScore = scores[i];
        }
    }

    for (int i = 0; i < n; i++) {
        if (scores[i] == maxScore) {
            cout << 'happy!';
        } else if (scores[i] == minScore) {
            cout << 'sad!';
        } else {
            cout << scores[i];
        }
        cout << ' ';
    }

    return 0;
}

输入样例 1:

5
80 90 70 60 100

输出样例 1:

80 90 70 60 happy!

输入样例 2:

3
100 50 70

输出样例 2:

happy! 50 70

原文地址: https://www.cveoy.top/t/topic/pqf1 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录