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

static int num = 0;
struct Donation {
    string name ;
    double money = 0;
};
int avg(int &a,int b) {
    return 2 * a * b / (a + b);
}
void input(vector<double> &score) {
    cout << "请输入10个成绩(最多十个):";
    while (cin >> score[num] && score[num] != 0) {
        num++;
        if (num == 10) break;
    }
}
void showScore(const vector<double> score) {
    for (auto a : score) {
        cout << a << "  ";
    }
    cout << endl;
}
double showAvg(const vector<double> score) {
    double sum = 0;
    for (auto a : score) {
        sum += a;
    }
    return sum / num;
}
int main(){
    vector<double> score(10,0);
    input(score);
    cout << "所有的成绩为:" << endl;
    showScore(score);
    cout << "平均成绩为:" << showAvg(score) << endl;

    return 0;
}

posted on 2023-12-14 20:01  wshidaboss  阅读(38)  评论(0编辑  收藏  举报