基本上我有,C++二维数组功能
double marks [STUDENTS][ASSIGNMENTS] = { (0.1,0.2,0.3,0.4,0.5,0.6,0.7),
(1,0.9,0.8,0.7,0.6,0.5,0.5),
(0.8,0.8,0.8,0.8,0.8,0.8,0.8),
(0.8,0.9,0.7,0.8,0.9,0.7,0.8),
(0.5,0.6,0.7,0.8,0.9,0.5,0.9)};
而且我想:double studentAverages [STUDENTS]
从studentAverages=calculateStudentAverages(marks);
使用:
double calculateStudentAverages (double marks[STUDENTS][ASSIGNMENTS]){
double averages[STUDENTS];
double average;
for (int i = 0; i < STUDENTS; i++) {
for (int j = 0; j < ASSIGNMENTS; j++) {
average = average + marks[i][j];
}
averages[i]=average/ASSIGNMENTS;
}
return averages;
}
,但我得到“无法从“双[转换5]'到'double'“和”无法从'double'转换为'double [5]'“
你会发现哪些错误? –
你应该避免原始数组,因为它们[行为奇怪](http://stackoverflow.com/a/10253277/365496) – bames53
函数被调用的行我得到: '=':无法从'double'转换为'double [5]' 函数中的返回行给出: 'return':无法从'double [5]'转换为'double' – user1810269