cout<
修改为
cout<
/*
p[3].score = 100
Press any key to continue
*/
#include
using namespace std;
class student {
public:
int num;
float score;
student(int n,float s):num(n),score(s){}
};
int main() {
student stud[5] = {student(101,78.5),student(102,85.5),student(103,98.5),
student(104,100.0),student(105,95.5)
};
void max(student*,int);
max(stud,5);
return 0;
}
void max(student *p,int n) {
float max_score = p[0].score;
int k = 0;
for(int i = 1;i < 5;i++) {
if(p[i].score > max_score) {
max_score = p[i].score;
k = i;
}
}
cout << "p[" << k << "].score = " << p[k].score << endl;
}