面试题答案
一键面试#include <iostream>
#include <string>
#include <vector>
class Student {
private:
std::string name;
std::vector<int> scores;
public:
double calculateAverageScore() {
if (scores.empty()) {
return -1;
}
int sum = 0;
for (int score : scores) {
sum += score;
}
return static_cast<double>(sum) / scores.size();
}
};