top1编程
← 返回题目
题解

【入门】买礼物?

1 条题解

  • 0
    @ 2026-7-29 0:17:17
    #include <iostream>
    #include <iomanip>
    #include <algorithm>
    using namespace std;
    
    int main() {
        int x, y, z;
        cin >> x >> y >> z;
    
        // 找出最大值和最小值
        int max_price = max({x, y, z});
        int min_price = min({x, y, z});
    
        // 总花费
        int total = max_price + min_price;
    
        // 平均花费
        double average = total / 2.0;
    
        // 输出
        cout << total << endl;
        cout << fixed << setprecision(1) << average << endl;
    
        return 0;
    }
    
    • 1